是否有一种简单的方法可以检索列中所有唯一值的列表,以及该值出现的次数?
示例数据集:
A A A B B C
......会回来:
A | 3 B | 2 C | 1
谢谢!
使用GROUP BY:
select value, count(*) from table group by value
使用HAVING进一步减少结果,例如只发生超过3次的值:
select value, count(*) from table group by value having count(*) > 3
SELECT id,COUNT(*) FROM file GROUP BY id