Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: How can I cut off a query after 3 lines?
> -----Original Message-----
> From: MKirk [mailto:mkirk_at_hot.ee]
>
> Q: how can you specify with a select statement how many rows
> are given as a
> result? I would only like to get the first three lines.....
>
> here is what I have....
>
>
> 1 SELECT machine_name, login, Count(login) AS CountOfLogin FROM
> login_history
> 2 group by machine_name, login > 3* order by count(login) desc > 4 ;
Please note that the "rownum < 4" clausee will be applied BEFORE a group by or order by.
At the end of each message sent to the list is a link to ORAFAQ. Click on the link, and go visit the SQL section. You will see there answers to the following questions:
Can one retrieve only the Nth row from a table?
http://www.orafaq.com/faqsql.htm#NTHROW
Can one retrieve only rows X to Y from a table?
http://www.orafaq.com/faqsql.htm#ROWXtoY
How does one select EVERY Nth row from a table?
http://www.orafaq.com/faqsql.htm#EVERYNTHROW
How does one select the TOP N rows from a table?
http://www.orafaq.com/faqsql.htm#TOP
![]() |
![]() |