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 |
|
surge3333
Starting Member
2 Posts |
Posted - 2012-02-21 : 11:07:44
|
| I have a select statement to return all users and the date/time entries from a table. I would like to further refine this to only return the most recent Start_Time entry for each user. That is I only want 1 entry returned for each user, and it should reflect the most recent START_TIME entry. This is what I currently have, but can't seem to move beyond it to get what I want.SELECT USER_NAME, START_TIME FROM HISTORY WHERE USER_NAME <> 'flintstone' order by USER_NAME, START_TIME desc Thanks |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2012-02-21 : 11:09:53
|
SELECT USER_NAME, max(START_TIME) as START_TIMEFROM HISTORYWHERE USER_NAME <> 'flintstone'group by USER_NAMEorder by USER_NAME No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
surge3333
Starting Member
2 Posts |
Posted - 2012-02-21 : 11:17:09
|
| Perfect. Thanks for this. |
 |
|
|
|
|
|