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.
SELECT col1, col2, COUNT(*) FROM Table1
GROUP BY col1, col2
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.