Jul 10, 2002 #1 Larshg Programmer Mar 1, 2001 187 DK Hi Yousing Oracle SQL - I only want the 10 top rows This is my sql sentence select * from prepaid.rating_report order by startdate desc; Right now I spooling it to at file and the making a hedad -10 on it - it works but I would rather do it in SQL. /Larshg
Hi Yousing Oracle SQL - I only want the 10 top rows This is my sql sentence select * from prepaid.rating_report order by startdate desc; Right now I spooling it to at file and the making a hedad -10 on it - it works but I would rather do it in SQL. /Larshg
Jul 10, 2002 #2 dickiebird Programmer Feb 14, 2002 758 GB You'd use rownum - see thread186-172936 HTH ;-) Dickie Bird db@dickiebird.freeserve.co.uk Upvote 0 Downvote
Jul 10, 2002 #3 angiole Programmer Oct 29, 2001 166 CA You may try the following as well: Select rownum, cola, colb from Table1 where rownum < 11 AA :~) Upvote 0 Downvote
Jul 10, 2002 #4 crufty Programmer Nov 12, 2001 32 US Actually, rownum < 11 returns the first 10 rows returned by the query NOT the top 10 rows. You have to wrap the ordered query in a 'select ... where rownum < N'. Example: select t0.* from (select * from prepaid.rating_report order by startdate desc) t0 where rownum < 11 ; Upvote 0 Downvote
Actually, rownum < 11 returns the first 10 rows returned by the query NOT the top 10 rows. You have to wrap the ordered query in a 'select ... where rownum < N'. Example: select t0.* from (select * from prepaid.rating_report order by startdate desc) t0 where rownum < 11 ;