Question : Show only first 25 rows of querry result

This query results in 10000 lines. I only would like to see the first 25 lines. I tried "top 25" and "where rownum<25" but this all returns error messages

select currency, datea vdate,valuea value , abs((VALUEb - VALUEa)/valueb)*100 percentdifference
from
(
select  A.FROM_CCY_ID currency, A.VDATE DateA, A.VALUE ValueA, B.VDATE DateB, b.value ValueB
from MAIN.INP_EXRATE a, MAIN.INP_EXRATE b
where A.FROM_CCY_ID = B.FROM_CCY_ID
and a.vdate >= to_date(sysdate-100)
and b.vdate >= to_date(sysdate-100)
order by a.vdate desc
) c
where datea = to_date(dateb+1)
order by percentdifference desc

Answer : Show only first 25 rows of querry result

Hi,

You have to use level of the query as a view:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
SELECT *
  FROM (select currency, datea vdate,valuea value , abs((VALUEb - VALUEa)/valueb)*100 percentdifference
from
(
select  A.FROM_CCY_ID currency, A.VDATE DateA, A.VALUE ValueA, B.VDATE DateB, b.value ValueB
from MAIN.INP_EXRATE a, MAIN.INP_EXRATE b
where A.FROM_CCY_ID = B.FROM_CCY_ID
and a.vdate >= to_date(sysdate-100)
and b.vdate >= to_date(sysdate-100)
order by a.vdate desc
) c
where datea = to_date(dateb+1)
order by percentdifference desc)
where rownum <= 25
Random Solutions  
 
programming4us programming4us