Jan 17, 2006 #1 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
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
Jan 18, 2006 #2 lewisp Programmer Aug 5, 2001 1,238 GB Code: SELECT * FROM tableA WHERE effdt = (SELECT MAX(effdt) FROM tableB); Upvote 0 Downvote
Jan 18, 2006 Thread starter #3 mrfritz44 MIS Nov 21, 2003 75 US 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? Upvote 0 Downvote
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?
Jan 18, 2006 #4 lewisp Programmer Aug 5, 2001 1,238 GB Code: SELECT * FROM tableA WHERE effdt IN ( SELECT effdt FROM ( SELECT effdt FROM tableB ORDER BY effdt desc ) WHERE rownum < 11 ); Upvote 0 Downvote
Code: SELECT * FROM tableA WHERE effdt IN ( SELECT effdt FROM ( SELECT effdt FROM tableB ORDER BY effdt desc ) WHERE rownum < 11 );
Jan 19, 2006 #5 nagornyi MIS Nov 19, 2003 882 US Code: SELECT * FROM (SELECT * FROM tableA ORDER BY effdt DESC) WHERE ROWNUM<=10 Upvote 0 Downvote