[英]Count of distinct values in a column
I have a table like 我有一张桌子
machine_id OS
---------- --
1 PC
2 PC
3 MAC
4 UNIX
5 PC
How do I return each OS and the number of times it occurs? 如何返回每个操作系统及其发生的次数? I can't group by OS because I would just get a distinct list of OS.
我无法按操作系统分组,因为我只会得到一个明确的操作系统列表。 I want to know how many times each OS occurs in the column
我想知道每个OS在列中出现了多少次
select OS, count(*)as TotalForOS
from table
group by OS
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.