Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"SELECT TOP" in Oracle SQL

Status
Not open for further replies.

mrfritz44

MIS
Nov 21, 2003
75
US
I need to select a record that has the latest date in a group of records. In MS SQL, I would say:

select * from tableA where effdt = (select top 1 effdt from tableB order by effdt desc)

How would I accomplish this in Oracle SQL?

Thank you,

Fred
 
Code:
SELECT *
FROM   tableA
WHERE  effdt = (SELECT MAX(effdt)
                FROM   tableB);
 
Thank you very much! OK, now for one I haven't needed yet, but likely will. How would select the top 5, 10, or 100?
 
Code:
SELECT *
FROM   tableA
WHERE  effdt IN ( SELECT effdt
                  FROM (
                    SELECT effdt
                    FROM   tableB
                    ORDER BY effdt desc )
                  WHERE  rownum < 11 );
 
Code:
SELECT * FROM
(SELECT * FROM tableA ORDER BY effdt DESC)
WHERE ROWNUM<=10
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top