Jul 10, 2002 #1 Larshg Programmer Joined Mar 1, 2001 Messages 187 Location 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 Joined Feb 14, 2002 Messages 758 Location 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 Joined Oct 29, 2001 Messages 166 Location 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 Joined Nov 12, 2001 Messages 32 Location 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 ;
Jul 11, 2002 #5 angiole Programmer Joined Oct 29, 2001 Messages 166 Location CA Correct! AA 8~) Upvote 0 Downvote