I have the following SQL querry:
select
ID, COLUMN1, COLUMN2
from
(select ID, COLUMN1, COLUMN2, row_number() over (order by 2 DESC) NO from A_TABLE)
where
NO between 0 and 100
What I am trying to do is to select the first 100 records of the query select ID, COLUMN1, COLUMN2 from ATABLE order by 2 DESC
And here are the problems:
Apparently, the order by clause is not working. I've noticed that I have to add another "
order by 2 DESC
" clause, just after "(...) from ATABLE
", for my querry to work. Is there something I do wrong? Or is it expectead behaviour?How can I add a where clause? Let's say I need to select only the first 100 records of the table "
where COLUMN1 like '%value%'
". I've tried adding the where clause after "(...) from ATABLE
" but it produced an error...
Help? Tnks.
PS: I'm using Oracle 10g R2.