Assuming I have the following table :
Table Files
id
size
In pseudo SQL I need this king of processing :
select id
where
size < S1 and (limit this clause to N1 results)
or
size > S2 and (limit this clause to N2 results)
I know Oracle defines rownum keyword to limit results.
But in my case, that does not work.
Do this require subselects ? How ? Is that possible to use multiple subselects ?
(This SQL would be generated by a java program with other where clauses, making the use of subselects difficult..)
Edit: I need to filter more than just different size.
SOLVED
SELECT *
FROM Files
WHERE
someField = 'stuff'
AND
someOtherField = 'other stuff'
AND
(
SELECT id FROM Files WHERE size <= S1 AND ROWNUM <= N1
UNION
SELECT id FROM Files WHERE size > S2 AND ROWNUM <= N2
)
sizeto two different numbers? I thoughtN1andN2were the number of results to return, not sizes.