I can't get what is the proper sql for this.
So I have users_tbl and users_access_log_tbl tables. Users_tbl table have user_id and user_name column. Users_access_log_tbl table have user_id and date_time_last_login columns.
If a user login, the Users_access_log_tbl will be inserted with the user id and time stamp of his login. So if that user log in 3 times, that user will have 3 records in user_access_log_tbl(obviously with 3 different time stamp). Now the user name of that user is in users_tbl. How can I query the two tables where the output is user name(the user name of the user should be only displayed once) and the date_time_last_login ( should be the users latest login date). Thanks..
This is it
select [user_name], max(l.date_time_last_login)
from users_tbl u
inner join users_access_log_tbl l
group by [user_name]
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)