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 |
|
jon_bulalaque
Starting Member
2 Posts |
Posted - 2005-08-29 : 05:09:43
|
| hi, i have a subquery that returns this resultTeam_ID User_ID LoggedHrs1 2 1803 2 1801 4 60404 4 60405 4 6040what i wanted to do now is select the max loggedhrs for the team_id and the user_id who logged that hrs.thanks in advance... |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-08-29 : 05:14:11
|
| Select Team_Id,User_Id,Max(LoggedHrs) from yourTable group by Team_Id,User_IdMadhivananFailing to plan is Planning to fail |
 |
|
|
jon_bulalaque
Starting Member
2 Posts |
Posted - 2005-08-30 : 01:44:08
|
| thanks for the reply... i tried that one but it would result toTeam_ID User_ID LoggedHrs1 4 60404 4 60405 4 60401 2 1803 2 180what i'm expecting isTeam_ID User_ID LoggedHrs1 4 60404 4 60405 4 60403 2 180 |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-08-30 : 01:55:48
|
| Try thisSelect max(Team_Id),User_Id,Max(LoggedHrs) from yourTable group by Team_Id,User_IdMadhivananFailing to plan is Planning to fail |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-08-30 : 02:14:30
|
| If the above does not work, this should workSelect distinct team_id,(select max(user_id) from yourTable where Team_id=T.team_id),(select max(LoggedHrs ) from yourTable where Team_id=T.team_id) from yourTable TMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|