Solved

Oracle 7.3.4 - Arbitrary limit rows returned - Limit or Top

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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
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.
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…

749 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