?
Solved

Oracle 7.3.4 - Arbitrary limit rows returned - Limit or Top

Posted on 2004-10-20
3
Medium Priority
?
892 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.
Suggested Courses

741 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