Hi all.

I'm trying to use ROW_NUMBER() in conjunction with ORDER BY and not having a lot of luck.

This is the query I'm using, which I found on the Derby wiki:

  SELECT * FROM (
    SELECT ROW_NUMBER() OVER(ORDER BY startdate ASC) AS row,
           id, startdate, enddate, ...
    FROM HistoryRecord
  ) AS tmp
  WHERE row >= ? AND row < ?

I have also tried what I consider to be the intuitive way:

  SELECT * FROM (
    SELECT ROW_NUMBER() OVER() AS row, id, startdate, enddate, ...
    FROM HistoryRecord
    ORDER BY startdate ASC
  ) AS tmp
  WHERE row >= ? AND row < ?

Both of these give an error at ORDER BY. Am I doing something wrong, or is this a missing part of the ROW_NUMBER() feature?

Daniel


--
Daniel Noll                            Forensic and eDiscovery Software
Senior Developer                              The world's most advanced
Nuix                                                email data analysis
http://nuix.com/                                and eDiscovery software

Reply via email to