| From: | "Scott Marlowe" <smarlowe(at)qwest(dot)net> |
|---|---|
| To: | "Cason, Kenny" <kenny(dot)cason(at)boeing(dot)com> |
| Cc: | pgsql-hackers(at)postgresql(dot)org |
| Subject: | Re: Selecting a specific row |
| Date: | 2004-08-04 22:39:01 |
| Message-ID: | 1091659141.27166.143.camel@localhost.localdomain |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Wed, 2004-08-04 at 16:11, Cason, Kenny wrote:
> Is there an easy way to select, say, the 15th row in a table? I can't
> use a sequence number because rows will sometimes be deleted resulting
> in the 15th row now being a different row. I need to be able to select
> the 15th row regardless of whether it is the same 15th row as the last
> select.
SQL itself has no natural ordering, so I'll assume you're doing
something like this:
select * from table order by seq_field
Just add offset and limit to the end:
select * from table order by seq_fields limit 1 offset 15;
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Oliver Jowett | 2004-08-04 22:39:07 | making integer_datetimes report on startup |
| Previous Message | Oliver Jowett | 2004-08-04 22:38:14 | Re: [HACKERS] postgres and Jdbc 2.0 |