Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: selecting _only_ the most recent entry

Re: selecting _only_ the most recent entry

From: <bookouri_at_hotmail.com>
Date: Tue, 07 Sep 1999 11:01:42 GMT
Message-ID: <7r2rai$9ci$1@nnrp1.deja.com>


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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US