tags:

views:

45

answers:

2

Hi I need small query here are my tables

user table  

userid username

user001 987
user002 123
user003 456

logintrack  

usrid lastlogin

user001 7/22/2009
user001 7/23/2009
user002 7/24/2009
user001 7/25/2009
user003 7/26/2009
user002 7/25/2009
user001 7/26/2990


Expected Output    

userid username lastlogin

user001 987 7/26/2009
user002 123 7/25/2009
user003 456 7/26/2009

Regards, Nagu

+2  A: 

Not sure but hope it works, please try it

SELECT u.userid, u.username, max(lt.lastlogin) FROM
user u, logintrack lt
WHERE u.userid = lt.userid
GROUP BY u.userid, u.username
Bhushan
Theoretically, that should also work ...
Ahsan Ali
+2  A: 

lastlogin is not a good name for that column, as it is a list of ALL login dates not just the last one.

Aidan
ok thank you i'll change it
Nagu