Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: selecting _only_ the most recent entry
I have a similar problem, except that I want to select only the most
recent record in a table.
If you are selecting from one table you can use the max(), min(), greatest(), least() etc. functions. But I need to do a join and select only the most recent record.
Example: emptable with names, addresstable with addresses, phone table with phones where you retain all old address and phones linked by empnum. I want to select empname, address, phone from emptable, addresstable, phone table where emp.empnum=add.empnum and emp.empnum = phone.empnum and ------ then I want only the most recent address or phone --- the address and phone tables have a date field that indicates when the address/phone was created. I just cant get this query to work and give me their current address (defined as the most recent dated address or phone)
If you are trying to pull from one table it should be easy to figure out using the greatest() least() etc.
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
Received on Tue Sep 07 1999 - 06:01:42 CDT
![]() |
![]() |