Re: getting the last N tuples of a query

Поиск
Список
Период
Сортировка
От Ben Chobot
Тема Re: getting the last N tuples of a query
Дата
Msg-id 3508844C-6813-431F-9638-C3D96578962E@silentmedia.com
обсуждение исходный текст
Ответ на getting the last N tuples of a query  ("Edmundo Robles L." <erobles@sensacd.com.mx>)
Ответы Re: getting the last N tuples of a query  (Kenichiro Tanaka <ketanaka@ashisuto.co.jp>)
Список pgsql-general
On Jul 8, 2010, at 4:17 PM, Edmundo Robles L. wrote:

> Hi!
>
> if a want the first   5,10,N tuples  of a query  (even without order)
> i just  have to do a:
> select  * from table limit 10;

That does not get the first 10 tuples, it merely gets 10 tuples. The database is free to return whichever 10 it can,
andin practice, the results will change given enough inserts or deletes. 

> So, what is the right way to do that  with no order????


Without an order by clause, there is no concept of "first" or "last". Once you have the order by clause, combine your
limitwith ascending or descending sorts to get the first or last, respectively. 

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

Предыдущее
От: "Edmundo Robles L."
Дата:
Сообщение: getting the last N tuples of a query
Следующее
От: Bryan Montgomery
Дата:
Сообщение: Re: GSS Authentication