Melvin Davidson wrote: > You can simply do: > second query (B): > > SELECT id > , ... > FROM events > WHERE id > MIN(ID) > AND id <= MAX(ID) > AND ... You probably meant to use a window function there: max(id) OVER () min(id) OVER () Yours, Laurenz Albe