Reputation: 337
I want to transform this so I could know for each country_code, how many people register with facebook, and how many register with email.
like:
country_code|facebook|email
---------------------------
AE | 4 | 5
AL | 11 | 10
thanks!
Upvotes: 0
Views: 18
Reputation: 62841
You can use sum
with case
and group by
:
select country_code,
sum(case when register_with = 'facebook' then 1 else 0 end) facebook,
sum(case when register_with = 'email' then 1 else 0 end) email
from yourtable
group by country_code
Upvotes: 2