[thelist] SQL Max Query Distinct

Feingold Josh S Josh.S.Feingold at irs.gov
Thu Nov 14 13:30:00 CST 2002


--
[ Picked text/plain from multipart/alternative ]
Rudy -

This is what I am looking for, but I think I need to embellish my example to
get a more useful answer.  I am getting an error when I try to jury rig
yours.  You the man, Rudy!

app 	dateChanged  firstName	lastName
3	3/24/00	moe 		doe
3	5/16/01 	curly		doe
3	7/1/02	larry 	doe
4	5/2/00	kate 		doe
4	7/6/01 	jane 		doe
4	8/16/02	janice 	doe

So I would want to be returned a recordset including larry and janice.

> and if you want the other columns from the row which has the latest date,
>
> select id, foo, bar, thedate
>  from yourtable XX
> inner
>  join ( select id
>              , max(thedate) as maxdate
>           from yourtable
>       group by id ) YY
>    on XX.id= YY.id
>   and XX.thedate = YY.maxdate


rudy

--
* * Please support the community that supports you.  * *
http://evolt.org/help_support_evolt/

For unsubscribe and other options, including the Tip Harvester
and archives of thelist go to: http://lists.evolt.org
Workers of the Web, evolt !



More information about the thelist mailing list