home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!mcsun!uknet!keele!csa09
- From: csa09@seq1.keele.ac.uk (Paul Singleton)
- Newsgroups: comp.databases.oracle
- Subject: Re: SQL*plus -- limiting maximum number of returned rows?
- Message-ID: <3894@keele.keele.ac.uk>
- Date: 1 Sep 92 13:05:17 GMT
- References: <1992Aug31.223520.28312@massey.ac.nz>
- Organization: University of Keele, England
- Lines: 23
-
- From article <1992Aug31.223520.28312@massey.ac.nz>, by M.W.Stern@massey.ac.nz (M.W. Stern):
-
- > > I am working on a report that is supposed to find the "top 5" items in
- > > a catagory. The query returns 0 or more rows based on the selection
- > > criteria, sorted in the appropriate order. Some queries return a dozen
- > > or more rows, but I'm only interested in the first 5.
-
- > I believe the answer to this goes something like this,
- >
- > SELECT value FROM table WHERE ROWNUM <= 5
-
- But I think the poster wanted the first N rows of a result relation, not
- a base table? This is one instance where the generalised SQL construct
-
- SELECT value FROM ( SELECT etc FROM etc WHERE etc )
- WHERE ROWNUM <= 5
-
- would be valuable, assuming that intermediate relations had ROWNUMs.
- ----
- __ __ Paul Singleton (Mr) JANET: paul@uk.ac.keele.cs
- |__) (__ Computer Science Dept. other: paul@cs.keele.ac.uk
- | . __). Keele University, Newcastle, tel: +44 (0)782 621111 x7355
- Staffs ST5 5BG, ENGLAND fax: +44 (0)782 713082
-