Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Oracle 7.3.4 - Arbitrary limit rows returned - Limit or Top

Posted on 2004-10-20
3
Medium Priority
?
898 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 2

Accepted Solution

by:
CallumT earned 1000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

597 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