I have the following table:
Mytable:
-------
col1 INT
col2 INT
col3 INT
And in postgresql I want to count the number of occurences that a combination of values in col1, col2, col3 occur.
For example if the Mytable
has the values:
col1 | col2 | col3 |
---|---|---|
1 | 5 | 3 |
1 | 8 | 3 |
1 | 5 | 3 |
1 | 5 | 3 |
1 | 5 | 3 |
1 | 5 | 4 |
1 | 5 | 4 |
2 | 5 | 3 |
1 | 8 | 3 |
How I can generate the following result:
col1 | col2 | col3 | count |
---|---|---|---|
1 | 5 | 3 | 4 |
1 | 8 | 3 | 2 |
2 | 5 | 3 | 1 |
1 | 5 | 4 | 2 |