Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> RE: How can I cut off a query after 3 lines?

RE: How can I cut off a query after 3 lines?

From: Jacques Kilchoer <Jacques.Kilchoer_at_quest.com>
Date: Fri, 04 May 2001 12:10:49 -0700
Message-ID: <F001.002F9C01.20010504113529@fatcity.com>

> -----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



Jacques R. Kilchoer
(949) 754-8816
Quest Software, Inc.
8001 Irvine Center Drive
Irvine, California 92618
U.S.A.
http://www.quest.com Received on Fri May 04 2001 - 14:10:49 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US