Reputation: 761
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
Upvotes: 0
Views: 552
Reputation: 32612
You just need to use GROUP BY
clause with multiple columns.
SELECT col1, col2, COUNT(*) FROM Table1
GROUP BY col1, col2
Upvotes: 1