Reputation: 63
I want to sum same values like this in col1 or col2 instead of integrations I want to sum of how much integrations in column I have ex. (2)
+-----------------------------------+------------+
| Col1 | Col2 |
+-----------------------------------+------------+
| Integrations | 01-2 |
| Integrations | 01-2 |
| Missions | 05-7 |
+-----------------------------------+------------+
Upvotes: 1
Views: 150
Reputation: 956
The below query gives you distinct results:
select Col1, count(distinct Col2)
from table
group by Col1
So number of Integrations
will be 1
.
If you want to have a total number of Integrations
, you should use this query:
select Col1, count(Col2)
from table
group by Col1
Which gives you the number of Integrations
of 2
.
Upvotes: 1
Reputation: 37473
You can try below - with distinct count
and group by
select col1,count(distinct col2)
from tablename
group by col1
Upvotes: 1