Re: Oracle Newbie : Getting only limited number of rows
From: David Ng <david_ng_at_attmysite.com>
Date: 1998/06/12
Message-ID: <6lqk7k$mcj$1_at_m5.att.net.hk>#1/1
order by salary ;
Date: 1998/06/12
Message-ID: <6lqk7k$mcj$1_at_m5.att.net.hk>#1/1
The rownum is assigned to a record before sorting. You get the first N records and then filter them with your criteria. As a result, you get less records than you expected.
Try merge join the table with dual table like the followings
Select /*+USE_MERGE*/ a.salary from target a, dual b where salary=DECODE(b.dummy(+), 'X', null, null) and rownum <= 50
order by salary ;
David Ng
avaneesh.arora wrote in message ...
>HI,
>
>I have the following problem :
>
>I want to select a limited number of rows from a table sorted on a
>particular set of columns. How do I structure my query to get, say Next N
>rows(50/100) based on the specified sort order. Limiting it by ROWNUM
limits
>the row count and does not work as desired.
>
>Please help.
>Thanks,
>Avaneesh
>
>
Received on Fri Jun 12 1998 - 00:00:00 CEST