I have a table like the following:
id website logInTime
1 Yahoo 1/1/2001 00:00:00
2 Google 1/1/2001 00:00:01
1 Yahoo 2/1/2014 00:00:00
2 Yahoo 2/1/2014 00:00:00
How can I retrieve the latest time of log in from each user based on the website?
Is that the query you're looking for?
SELECT T.id
,T.website
,MAX(T.logInTime) AS [lastLogInTime]
FROM yourTable T
GROUP BY T.id, T.website
Hope this will help you.
select t.id, t.website, max(logInTime)
from table t
group by t.id, t.website
this should work
select id
, website
, max(logInTime) as latesttime
from tableName
group by id, website
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.