|
Knowledge Base
Document information| Document ID: | 769 |
|---|
| Subject: | Retrieving the Top-N or Bottom-N Rows from a SQL Table |
|---|
| Creation date: | 7/29/09 2:59 PM |
|---|
| Last modified on: | 7/29/09 3:09 PM |
|---|
Details
Following example show how to retrieve top-N or bottom-N rows from
an Oracle table. This example makes use of a pseudo-column in Oracle
called ROWNUM and we want to retrieve top 5 rows.
select * from (select * from CUSTOMER order by ID)
WHERE ROWNUM <= 5
Note: that this example makes use of a feature called an "inline
view" that is supported by Oracle but may not be supported in other
RDBMS.
User commentsPosted by Meg on 10/25/10 5:12 PM Getting Error" Error: ERROR: Attribute 'ROWNUM' not found (State:42S22, Native Code: 1F) Posted by Yvone on 3/24/10 10:24 AM select * from T_REF_LIST where rownum <=5
I got error message
Error: ERROR: Attribute 'ROWNUM' not found (State:42S22, Native Code: 1F)
Add a comment to this document
Do you have a helpful tip related to this document that you'd like to share
with other users? Please add it below. Your name and tip will appear at the
end of the document text.
|