Hi,

I have a table with a DATE as the primary key, so there's one row per date. I need a query that returns exactly three rows: The one indexed by the date I select (WHERE date='20050302'), plus the two neighbouring dates; the previous and following entries relative to the date I selected.

My table would look like this:

20050301 | abc
20050303 | def
20050308 | ghi
20050310 | jkl
20050315 | mno
20050320 | pqr

I run a SELECT query with "WHERE date='20050308'" and I get 'ghi'. Now what I want in addition to that are the two neighbouring rows, in this case 'def' and 'jkl'. I do not know the dates of those entries, so I can't explicitly include them in the WHERE clause.

The query i'm looking for will obviously contain "ORDER BY date", but how do I get the previous and following row relative to the one I select?

Thanks in advance!