开发者社区 问答 正文

MySQL COUNT DISTINCT?mysql

我正在尝试收集昨天在我的CP中不同访问的次数,然后计算它们。

SELECT DISTINCT user_id as user, site_id as site, ts as time FROM cp_visits WHERE ts >= DATE_SUB(NOW(), INTERVAL 1 DAY) 由于某些原因,这会使用相同的站点ID提取多个结果。...我如何只提取并计算不同的site_id cp登录数?

展开
收起
保持可爱mmm 2020-05-16 22:05:09 461 分享 版权
1 条回答
写回答
取消 提交回答
  • Select Count(Distinct user_id) As countUsers , Count(site_id) As countVisits , site_id As site From cp_visits Where ts >= DATE_SUB(NOW(), INTERVAL 1 DAY) Group By site_id来源:stack overflow

    2020-05-16 22:18:09
    赞同 展开评论