SQL last user login date

I have a table that logs user logons called user_logon, with fields id, user and user_login_time.

id      user              user_description      user_login_time
1      user_a      user a                  10-10-2008 10:23
2      user_a      user a                  10-10-2008 11:25
3      user_a      user a                  11-10-2008 10:00
4      user_b      user b                  10-10-2008 10:23
5      user_b      user b                  10-10-2008 10:25
6      user_b      user b                  12-10-2008 10:00

I wish to select the last time that each user has logged on. How do I do this?
thehazeAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

tigin44Commented:
use aggragate funtion suc the one below.

select user, max(user_login_time)
from Table
group by user
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ErnariashCommented:
If you need user_description or extradata on your select use a subquery
like...hope it help you
 

SELECT *
FROM user_logon 
WHERE EXISTS ( 
	SELECT 1 FROM
		 (select user, max(user_login_time) Last_login_time
                   from user_logon
                   group by user)  T
      WHERE user_logon.user = T.user 
	    AND Last_login_time=user_logon .user_login_time 
 
)

Open in new window

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2005

From novice to tech pro — start learning today.