mysql query the latest log record of different users/mysql query the latest record of different users

select a.id,a.start_time,a.online_time,a.end_time,a.user_id

from
(
SELECT id,start_time,online_time,end_time,user_id
FROM logonlinetb
where
businessId = '05051357441470000'
and group_id = '11071459147070001'
ORDER BY end_time DESC
) a
GROUP BY a.user_id

where start_time is the start time online_time is the online duration, end_time is the last end time, user_id is the user id

to query the latest log record of different users in the log table, end_time is the latest

Other query conditions
businessId is the business System id
group_id is the user group id under the business system

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326085791&siteId=291194637