Solved

SELECT first record

Posted on 2001-09-05
3
1,713 Views
Last Modified: 2010-05-18
I have a simple subquery in an Oracle SQLPLUS SELECT, but it returns > 1 records.
How do I  select only the first or top record?


0
Comment
Question by:vd
  • 2
3 Comments
 
LVL 5

Accepted Solution

by:
ser6398 earned 50 total points
ID: 6458704
select *
from my_table
where rownum <= 1
0
 
LVL 5

Expert Comment

by:ser6398
ID: 6458707
other options in a subquery:

select *
from my_table1
where id = (
  select max(id)
  from my_table2
            );


or


select *
from my_table1
where id IN (
  select id
  from my_table2
     );


0
 

Author Comment

by:vd
ID: 6464229
Thanks!
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.

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…
I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

773 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