Answers:
总体
SELECT
COUNT(DISTINCT `site_id`) as distinct_sites
FROM `cp_visits`
WHERE ts >= DATE_SUB(NOW(), INTERVAL 1 DAY)
或每个站点
SELECT
`site_id` as site,
COUNT(DISTINCT `user_id`) as distinct_users_per_site
FROM `cp_visits`
WHERE ts >= DATE_SUB(NOW(), INTERVAL 1 DAY)
GROUP BY `site_id`
time
结果中没有该列是没有意义的-因为您正在聚集行,所以显示一个特定的内容time
是无关紧要的,除非它是the min
或max
您在后面。
Count(Distinct user_id)
”