Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

looking for Number of Members in each country whose preference game is set to NES

SQL Number of Members in each country whose preference game is set to NES

EXPECTED OUTPUT

COUNT(AUD)  COUNT(EUR)  COUNT(IND)  COUNT(LAO)  COUNT(USA)  COUNT(ZWE)  
    3           2           0           0       2           1

Here is the SQL fiddle

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

http://sqlfiddle.com/#!9/a15ec9f/3

>Solution :

We pivot.

select *
from   t
pivot(count(MEMBER_ID) for COUNTRY_ID in('AU' as "count(AU)", 'US' as "count(US)", 'LAO' as "count(LAO)", 'IND' as "count(IND)", 'DE' as "count(DE)", 'ZW' as "count(ZW)")) p  
count(AU) count(US) count(LAO) count(IND) count(DE) count(ZW)
3 7 0 0 4 2

Fiddle

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading