Re: Re: "Oracle's ROWNUM"

Поиск
Список
Период
Сортировка
От Hiroshi Inoue
Тема Re: Re: "Oracle's ROWNUM"
Дата
Msg-id 3B650A78.1926B0C5@tpf.co.jp
обсуждение исходный текст
Ответ на Re: Re: "Oracle's ROWNUM"  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Re: "Oracle's ROWNUM"  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
Svenne Krap wrote:
>
> On Mon, 30 Jul 2001 00:05:42 +0000 (UTC), tgl@sss.pgh.pa.us (Tom Lane)
> wrote:
>
> >Svenne Krap <usenet@krap.dk> writes:
> >> I thought of the possibility to do something like
> >
> >> select rownum as artistplacement, s.* from (select rownum as
> >> techplacement, * from ranking order by technical_points) order by
> >> s.artiste_points
> >
> >This is an interesting example, but I do not believe that ROWNUM could
> >really be used that way.  You are assuming that ROWNUM is computed after
> >the rows are sorted --- but in fact SQL requires the target expressions
> >of a SELECT to be computed before ORDER BY is applied.  What would you
> >expect to happen with
> >       SELECT rownum, * FROM table ORDER BY 1
> >
> >Does anyone know what the actual semantics of Oracle's ROWNUM are?
>
> Well, I'm quite positive, that Oracle calculates ROWNUM after having
> ordered the set. As I'm not sure, ROWNUM is counted as part of the
> resultset (until it is selected of a second select)
>

Isn't it a little different ?
Oracle doc says.

If you embed the ORDER BY clause in a subquery and place the ROWNUM
condition in the top-level query, you can force the ROWNUM condition
to be applied after the ordering of the rows. For example, the
following query returns the 10 smallest employee numbers. This
is sometimes referred to as a "top-N query":

SELECT * FROM
   (SELECT empno FROM emp ORDER BY empno)
   WHERE ROWNUM < 11;


regards,
Hiroshi Inoue

В списке pgsql-general по дате отправления:

Предыдущее
От: will trillich
Дата:
Сообщение: RULE vs TRIGGER
Следующее
От: "Kapil Tilwani"
Дата:
Сообщение: C / FoxPro