[英]Select Distinct multiple columns, count distinct
How do you select distinct, and count of distinct? 您如何选择不重复和不重复计数? I have a table: 我有一张桌子:
col1 col2
1 1
1 0
0 0
0 1
1 1
0 0
And I'm trying to get this: 我正在尝试得到这个:
col1 col2 count
1 1 2
1 0 1
0 0 2
0 1 1
You just need to use GROUP BY
clause with multiple columns. 您只需要对多列使用GROUP BY
子句。
SELECT col1, col2, COUNT(*) FROM Table1
GROUP BY col1, col2
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.