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 |
Poppy
Starting Member
5 Posts |
Posted - 2006-05-05 : 04:01:28
|
Hi I have a table that logs the dates and times when a user logs on. I have a list of about 500 hundred users and I need to find the most recent date for each of them. So far I have the following query:select * from userlog where userid in ('jen01','sanet27','jamie'...etc) (and last log on date was ...)I need to have a list that looks something like below: jen01 2006/03/01sanet27 2006/03/03jamie 2006/05/05 Thanks for all your help in advanceKind RegardsThe early bird might catch the worm, but the second mouse sure gets the cheese. |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-05-05 : 04:03:56
|
[code]select userid, max(last_logon_date)from yourtablegroup by userid[/code] KH |
|
|
jen
Master Smack Fu Yak Hacker
4110 Posts |
Posted - 2006-05-05 : 04:04:22
|
use group by...select userid,max(datelogon)from userloggroup by useridhaving userid in ('jen01','sanet27','jamie'...etc) (and last log on date was ...) --guess you won't need this unless you want to specify a range?--------------------keeping it simple... |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
Poppy
Starting Member
5 Posts |
Posted - 2006-05-05 : 05:02:20
|
Hi Guys Thank you all for your prompt response. I really appreciate it.Kind RegardsThe early bird might catch the worm, but the second mouse sure gets the cheese. |
|
|
|
|
|