DBAsupport.com Forums - Powered by vBulletin
Results 1 to 4 of 4

Thread: how to retrive top 5 rows fro a result set

Hybrid View

  1. #1
    Join Date
    May 2002
    Posts
    2
    select nct.user_id,count(so.order_no) as ordercount
    from NETCARROTS_TRANSACTIONS nct, cust_info ci, shopcart_order so
    where nct.user_id=ci.user_id and status='y' and so.order_no=nct.order_no
    and so.dateorder between '01-feb-2002'
    and '01-apr-2002' group by nct.user_id
    order by ordercount desc

    the above query return 15 rows i want to retrive top 5 out of this resultset... but i am not able to get ... is there any to do this...

    thanks

  2. #2
    Join Date
    May 2002
    Posts
    2,645
    Top five or first five?

    Add "where rownum < 6" to get first five rows.

  3. #3
    Join Date
    May 2002
    Posts
    2
    no i want top 5 rows...... and rownum is not working in this case don't know why.....

  4. #4
    Join Date
    Dec 2001
    Posts
    221
    select * from (
    select nct.user_id,count(so.order_no) as ordercount
    from NETCARROTS_TRANSACTIONS nct, cust_info ci, shopcart_order so
    where nct.user_id=ci.user_id and status='y' and so.order_no=nct.order_no
    and so.dateorder between '01-feb-2002'
    and '01-apr-2002' group by nct.user_id
    order by ordercount desc )
    where rownum < 6
    Santosh Jadhav
    8i OCP DBA

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width