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 |
|
Beast777
Starting Member
10 Posts |
Posted - 2007-05-22 : 14:18:34
|
| Right now I have added several records for two different people. I want to return the last date the person did the test, their name and the number of pushups they did. If my data was thisSN CheckDate PushupSam 01/01/07 20Sam 02/01/07 22Ted 03/01/07 12Sam 05/01/07 14Ted 06/07/01 10I would hope to get back this:Sam 05/01/07 14Ted 06/07/01 10I am able to write this "SELECT SN, Max(CheckDate) as Expr1 from FitCheck group by SN" and that will give me the Name and Date but as soon as throw the Pushup into the mix, I am lost. Help please. |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2007-05-22 : 14:22:15
|
| [code]select t1.*from Table1 t1 join (select SN, max(CheckDate) as CheckDate from Table1 group by SN) t2 on t1.SN = t2.SN and t1.CheckDate = t2.CheckDate[/code]_______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenp |
 |
|
|
Beast777
Starting Member
10 Posts |
Posted - 2007-05-22 : 14:38:24
|
| Amazing, that was fast, Thank you ever so much. |
 |
|
|
|
|
|