[SQL] SELECT: retrieve only 2 rows next to known row

2005-09-09 Thread Nikolay Samokhvalov
Hi, My knowledge of PostgreSQL's SQL is not good, but I know ISO/ANSI SQL:2003 (basics) quite well. I've encountered with following task. I have one SELECT statement with ORDER BY clause; and know, that result set for this SELECT contains row with ID = 1000 (just for example). I don't know the po

Re: [SQL] SELECT: retrieve only 2 rows next to known row

2005-09-09 Thread Bruno Wolff III
On Fri, Sep 09, 2005 at 16:23:00 +0400, Nikolay Samokhvalov <[EMAIL PROTECTED]> wrote: > > I've encountered with following task. I have one SELECT statement with > ORDER BY clause; and know, that result set for this SELECT contains > row with ID = 1000 (just for example). > I don't know the posi

Re: [SQL] SELECT: retrieve only 2 rows next to known row

2005-09-09 Thread Tom Lane
Nikolay Samokhvalov <[EMAIL PROTECTED]> writes: > I don't know the position of this row in result set, but I want to > retrieve 2 rows that are next to this one. In general there is no such thing as "the row next to this one". SQL treats all data sets as unordered, up until the point where you d