本文介绍了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
发布评论