Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Sql question
I was wondering if there is a way to use a single query in the following scenario:
Table A contains the columns id(PK), fid(FK), status_date, status
Sample data is:
1 id_a 20-Mar-2000 s1 2 id_a 12-Apr-2000 s2 3 id_b 15-Jan-2000 s4 4 id_b 31-Jul-2000 s3 5 id_b 24-Aug-2000 s9 6 id_c 19-May-2000 s6 7 id_c 25-Aug-2000 s7
I want to be able to select each column (select *) where fid equals id_a or id_c but I only want one row returned for all the instances of id_a and one row for all the instances of id_c based upon the most recent status_date for the given fid. In this example, I would want rows with id = 2 and id = 7 returned. Can anyone tell me the sql statement that would produce this result? Thanks for any help you can give me on this.
Sent via Deja.com http://www.deja.com/
Before you buy.
Received on Mon Oct 16 2000 - 15:32:39 CDT