我正在简单的表中收集点击次数
user_id | count | meta
=====================================
1 | 3 | http://google.com
1 | 2 | http://twitter.com
2 | 1 | http://google.com
3 | 2 | http://example.com
4 | 1 | http://google.com
现在我想知道
输出应该是
uniq | total
=============
4 | 9
目前我有
SELECT COUNT(DISTINCT count) AS uniq, SUM(count) AS total FROM my_table
但结果是三个唯一身份用户四:
答案 0 :(得分:2)
您需要计算用户数:
SELECT COUNT(DISTINCT user_id) AS uniq, SUM(count) AS total
----------------------^
FROM my_table;