MySQL COUNT DISTINCT

编程入门 行业动态 更新时间:2024-10-25 14:26:25
本文介绍了MySQL COUNT DISTINCT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正试图收集昨天在我的客户服务中进行的不重复访问的次数,然后对它们进行计数.

I'm trying to collect the number of distinct visits in my cp yesterday, then count them.

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登录数?

For some reason this is pulling multiple results with the same site id....how do i only pull and count the distinct site_id cp logins?

推荐答案

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

更多推荐

MySQL COUNT DISTINCT

本文发布于:2023-11-22 05:26:44,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1616136.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:MySQL   COUNT   DISTINCT

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!