I've the following SQL structure:
SELECT * FROM (
SELECT subquery.* FROM (
SELECT some_columns
FROM some_tables
WHERE junctions_critereas
GROUP BY some_columns
UNION
SELECT some_columns
FROM some_tables
WHERE junctions_critereas
GROUP BY some_columns) subquery
GROUP BY some_columns)
WHERE ROWNUM > startRecord AND ROWNUM <= endRecord;
- If I exclude the ROWNUM criterea the query returns 33 records.
- If I put startRecord = 0 and endRecord = 10 the query returns the 10 first records.
- If I put startRecord = 0 and endRecord = 20 the query returns the 20 first records.
- If I put startRecord = 0 and endRecord = 40 the query returns all the 33 records.
- If I put startRecord = 10 and endRecord = 20 the query returns no records.
If I change the final WHERE to WHERE ROWNUM BETEEW startRecord AND endRecord
I got the same results.
Some one knows what's happening here?