Re: Getting 'n-1'th record.
От | Jeff Eckermann |
---|---|
Тема | Re: Getting 'n-1'th record. |
Дата | |
Msg-id | 023901c12a53$11c61190$279c10ac@INTERNAL обсуждение исходный текст |
Ответ на | Getting 'n-1'th record. (Bhuvan A <bhuvansql@yahoo.com>) |
Список | pgsql-sql |
SELECT * FROM table ORDER BY field DESC LIMIT 1 OFFSET 1; This way you don't need to know the value of "n" in advance. The descending ORDER BY is to indicate a reversal of your intended ordering, so as to make the n-1'th record the second record. Note that getting the n-1'th record from an unordered list will not give meaningful results, because you cannot predict what will be returned. ----- Original Message ----- From: "Bhuvan A" <bhuvansql@yahoo.com> To: <pgsql-sql@postgresql.org> Sent: Tuesday, August 21, 2001 2:41 AM Subject: Getting 'n-1'th record. > > hi all, > > consider below.. > > An sql query results with 'n' records. OK. > I need ONLY the 'n-1'th record. > > > HOW CAN I GET THIS? > > Thankx in advance! > > ====================================================================== > Q: What's the difference between the 1950's and the 1980's? > A: In the 80's, a man walks into a drugstore and states loudly, "I'd > like some condoms," and then, leaning over the counter, whispers, > "and some cigarettes." > > ====================================================================== > > Regards, > Bhuvaneswar. > > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster > >
В списке pgsql-sql по дате отправления: