I have a table :
I have a query which gives me
And I want something like this :
Query used for above result is :
select ucountry,sum(Males) Males,sum(females ) Females from (
select ucountry,
case when gender = 'M' then count(1) else 0 end as Males,
case when gender = 'F' then count(1) else 0 end as females
from testing.test_users
group by ucountry, gender
) a group by ucountry;
I am definitely not doing the best thing here. Any thing you guys think would be better?