Solved

Oracle 7.3.4 - Arbitrary limit rows returned - Limit or Top

Posted on 2004-10-20
3
889 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 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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

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 …
Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines

688 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