DB2 SQL query: back to LIMIT OFFSET statements, fix query logic