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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2002-11-05 : 08:25:42
|
| Navinderjit writes "I am having a table 'test_attempt' with following fields:employee_id, name, manager_email, test_id, test_attempt_date, attempt_number,session_id.I need to fetch test_id, test_attempt_date, attempt_number, session_id from above table for each 'employee_id' where its 'test_attempt_date' is maximumIts very urgent for me..Thanks a ton..Navinder" |
|
|
Andraax
Aged Yak Warrior
790 Posts |
Posted - 2002-11-05 : 08:40:03
|
| You colud try somethin like this (haven't tested it):select employee_id, test_id, test_attempt_date, attempt_number, session_idfrom test_attempt ta,(select employee_id, max(test_attempt_date) as maxdate from test_attempt group by employeeid) as mdwhere ta.employee_id=md.employee_id and ta.test_attempt_date=md.maxdate |
 |
|
|
Page47
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2002-11-05 : 08:45:47
|
| Use a derived table to get the set of employee_id's and the associated max(test_attempt_date) grouped by employee_id. Then join this back to you base table on employee_id and the derived date.An hurry up ...EDIT: or let someone else write the code for you ...Jay White{0}Edited by - Page47 on 11/05/2002 08:46:38 |
 |
|
|
Andraax
Aged Yak Warrior
790 Posts |
Posted - 2002-11-05 : 09:03:11
|
| Sorry... Never had any teaching skills :( |
 |
|
|
|
|
|
|
|