这是我的查询
SELECT count(*) as count
FROM `tbl_track`
GROUP BY `user_id`
其结果是(1人访问2次+1人访问2次+1人访问1次)
Count
2
2
1
我想要一个结果(2 人访问 2 次 + 1 人访问 1 次)
Count
2
1
这是我的查询
SELECT count(*) as count
FROM `tbl_track`
GROUP BY `user_id`
其结果是(1人访问2次+1人访问2次+1人访问1次)
Count
2
2
1
我想要一个结果(2 人访问 2 次 + 1 人访问 1 次)
Count
2
1
SELECT count(*) as `count`, `visit_times`
FROM (
SELECT count(*) as `visit_times`
FROM `tbl_track`
GROUP BY `user_id`
) AS t GROUP BY `visit_times`
尝试这个:
select cnt as user_count,COUNT(*) as count
from
(
SELECT COUNT(*) as cnt
FROM tbl_track
GROUP BY userid)a
group by cnt
尝试这个:
SELECT DISTINCT VisitsCount
FROM
(
SELECT COUNT(*) AS VisitsCount
FROM TableName
GROUP BY UserId
) T