Is it possible to write a SQL statement that retrieves X consecutive records after a record with criteria Y, from a list with criteria Z?
for example, given this table :
id name
------------------------------
1 aaa
5 bbb
10 ccc
15 ddd
20 eee
25 fff
30 ggg
I first apply criteria Z, something like
SELECT * WHERE (id>4) AND (id<26) ORDER BY id ASC
then I am left with a list:
id name
------------------------------
5 bbb
10 ccc
15 ddd
20 eee
25 fff
I want to know if it’s possible to retrieve 2 records from this list from where name=’ddd’ (or some other criteria Y), ie, to return the “ddd” and “eee” records in the above example.
It must possible to do this directly in SQL, but I’m afraid I lack the mileage to know it.
In your wording: