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

Home -> Community -> Usenet -> c.d.o.server -> Re: please help me in building a SQL query...........

Re: please help me in building a SQL query...........

From: <fitzjarrell_at_cox.net>
Date: 5 Jan 2005 05:52:36 -0800
Message-ID: <1104933156.897490.272170@z14g2000cwz.googlegroups.com>

techimadhu wrote:
> thanks for replying.
> actually i have some more fields in address table which i want to
> display, but i cant apply max to all of them.

The previous reply doesn't help that much, in that max(Addresstext) is not what you need returned. Your requirement dictates the use of a subquery to return the max(validitystartdate) and the addressguid associated with it:

select select p.personuid, a. addresstext from person2address p, address a
where a.addressguid = p.addressguid
and (a.addressguid, a.validitystartdate) in (select addressguid, max(validitystartdate) from address
group by addressguid);

Something along this line would allow you to return any number of values in the driving select and still use the max(validitystartdate) to isolate the records you need.

David Fitzjarrell Received on Wed Jan 05 2005 - 07:52:36 CST

Original text of this message

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