• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1732
  • Last Modified:

SELECT first record

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
vd
Asked:
vd
  • 2
1 Solution
 
ser6398Commented:
select *
from my_table
where rownum <= 1
0
 
ser6398Commented:
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
 
vdAuthor Commented:
Thanks!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now