Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
gamaz2
Starting Member
31 Posts |
Posted - 2008-07-07 : 18:01:44
|
Hi,I have a prototype table named tblTemp that has the following rows:Name EditedProject DateSam 100A 04/03/08Mary 200C 02/01/08Tim 101P 03/04/08Tim 101P 05/04/08Robin 109T 06/11/08Sam 100A 05/21/08Sam 100A 06/25/08Now I have to list the rows that corresponds to the maximum editing date. Thus the desired resultset will be as follows:Name EditedProject DateMary 200C 02/01/08Tim 101P 05/04/08Robin 109T 06/11/08Sam 100A 06/25/08I have no idea how to handle the above. Any help is appreciated. Thanks |
|
GilaMonster
Master Smack Fu Yak Hacker
4507 Posts |
Posted - 2008-07-08 : 02:40:18
|
Max date by name or by edited or both?--Gail ShawSQL Server MVP |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-07-08 : 06:38:08
|
[code]SELECT t.*FROM tblTemp tINNER JOIN (SELECT Name,MAX(Date) AS MaxDate FROM tblTemp GROUP BY Name)tmpON tmp.Name=t.NameAND tmp.MaxDate=t.Date[/code] |
 |
|
gamaz
Posting Yak Master
104 Posts |
Posted - 2008-07-08 : 11:19:38
|
Thanks Vaisakh for the generous help. It worked perfect. Gail sorry for not been explicitly clear in my statement. I meant to say to extract row corresponding to the latest date. Thanks. |
 |
|
|
|
|