I'm pretty sure you've gotten it wrong in numerous ways, so far. And you probably won't get it right any time soon. So why waste your precious time on SQL tweaking, when you could be implementing business logic? Let me explain... It hasn't been until the recent SQL:2008 standard that what MySQL users know as … Continue reading Stop Trying to Emulate SQL OFFSET Pagination with Your In-House DB Framework!
For your reference, here is a list of publicly available SQL standard documents. Some are very late draft versions, where the final version is closed source and has to be purchased from ISO or ANSI directly: SQL-92 http://www.contrib.andrew.cmu.edu/~shadow/sql/sql1992.txt SQL:1999 http://web.cs.ualberta.ca/~yuan/courses/db_readings/ansi-iso-9075-2-1999.pdf SQL:2003 http://www.wiscorp.com/sql_2003_standard.zip SQL:2008 (preliminary) http://www.wiscorp.com/sql200n.zip The links were taken from here: http://wiki.postgresql.org/wiki/Developer_FAQ