Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Register Now and get your question answered!
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Repeated users...
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

2 Posts

Posted - 02/08/2013 :  06:59:11  Show Profile  Reply with Quote
i have two tables:
First one: Users with:
id int (primary)
name varchar

and a second user_register with:
date_usage DateTime

i need to get the list of users with the last access (not all the access.

i made this

select distinct name, date_usage from users
left join user_register on id_user = id

but i get a all users with all the access register...

i need only one per user with the last login

Any idea?

Thank's in advance


Edited by - marcobranco1975 on 02/08/2013 06:59:48

Premature Yak Congratulator

22864 Posts

Posted - 02/08/2013 :  07:02:46  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
select name, max(date_usage) as date_usage from users
left join user_register on id_user = id
group by name


Failing to plan is Planning to fail
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.77 seconds. Powered By: Snitz Forums 2000