2022-03-18 14:29:43 +03:00
|
|
|
SELECT s2.user_id, sum(c) as count, total, (sum(c) / total) as ratio
|
|
|
|
FROM (
|
2022-03-18 15:41:32 +03:00
|
|
|
SELECT time, user_id, entity, is_write, branch, editor, machine, operating_system, COUNT(time) as c
|
2022-03-18 14:29:43 +03:00
|
|
|
FROM heartbeats
|
2022-03-18 15:41:32 +03:00
|
|
|
GROUP BY time, user_id, entity, is_write, branch, editor, machine, operating_system
|
2022-03-18 14:29:43 +03:00
|
|
|
HAVING COUNT(time) > 1
|
|
|
|
) s2
|
|
|
|
LEFT JOIN (SELECT user_id, count(id) AS total FROM heartbeats GROUP BY user_id) s3 ON s2.user_id = s3.user_id
|
|
|
|
GROUP BY user_id
|
|
|
|
ORDER BY count DESC;
|