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?
Keep
in mind also that now Oracle has analitical functions like rank etc. which can
be used to resolve such problems and SQL is much simpler.
<FONT face=Arial color=#0000ff
size=2>
Alex
Hillman
<FONT face=Tahoma
size=2>-----Original Message-----From: Jacques Kilchoer
[mailto:Jacques.Kilchoer_at_quest.com]Sent: Friday, May 04, 2001 3:35
PMTo: Multiple recipients of list ORACLE-LSubject: 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.... > <FONT
size=2>> > 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?
<A target=_blank
href="http://www.orafaq.com/faqsql.htm#NTHROW">http://www.orafaq.com/faqsql.htm#NTHROW
Can one retrieve only rows X to Y from a table?
<A target=_blank
href="http://www.orafaq.com/faqsql.htm#ROWXtoY">http://www.orafaq.com/faqsql.htm#ROWXtoY
How does one select EVERY Nth row from a table?
<A target=_blank
href="http://www.orafaq.com/faqsql.htm#EVERYNTHROW">http://www.orafaq.com/faqsql.htm#EVERYNTHROW
How does one select the TOP N rows from a table?
<A target=_blank
href="http://www.orafaq.com/faqsql.htm#TOP">http://www.orafaq.com/faqsql.htm#TOP
![]() |
![]() |