Solved

Oracle 7.3.4 - Arbitrary limit rows returned - Limit or Top

Posted on 2004-10-20
3
864 Views
Last Modified: 2008-01-09
Hi Experts,

Sorry, Its been years since I used Oracle, and my sql is rusty.  I need to select some examples of different account types for training purposes.  They require 20 of each type, 1 for each member in the class and a few spare.  

I logged onto the training region (Oracle7 Server Release 7.3.4.0.1)  and using sqlplus(PL/SQL Release 2.3.4.0.0) typed:

select key_1, acct_type, int_cat, curr_status from invm where acct_type='2200' and curr_status='00' limit 20;

and got :
ERROR at line 1:
ORA-00933: SQL command not properly ended

I thought 'Maybe my memory is faulty, maybe its top...'(access is more recent in my memory)

select top 20 key_1, acct_type, int_cat, curr_status from invm where acct_type='2200'  and curr_status='00';

ERROR at line 1:
ORA-00923: FROM keyword not found where expected

so its not that.  

How can get 20 results only using sql?  After this, I need to generate about 25 more lists, so I'll script it and spool to file, but I need to get this bit working first.

Luke
0
Comment
Question by:Hecatonchires
  • 2
3 Comments
 
LVL 2

Accepted Solution

by:
CallumT earned 250 total points
ID: 12366369
Use the rownum field.

e.g. select key_1, acct_type, int_cat, curr_status from invm where acct_type='2200' and curr_status='00'  where rownum < 21 ;

will give you the first 20 rows from the resultset.
0
 
LVL 7

Author Comment

by:Hecatonchires
ID: 12366386
To many wheres, but thankyou!
0
 
LVL 2

Expert Comment

by:CallumT
ID: 12366409
Ooops

That should have been   AND rownum < 21

Your'e welcome
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
Via a live example, show how to take different types of Oracle backups using RMAN.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now