mysql - Query on my sql db -


i have 2 different query:

select nazione,        count(*) gold   `summertotalmedal`   medaglia = 'gold'    , sport = 'athletics'   group nazione  order gold desc 

and

select nazione,         count(*) silver   `summertotalmedal`   medaglia = 'silver'    , sport = 'athletics'   group nazione  order silver desc 

is there way join query such 2 different output on 2 different coloumns?

you can use conditional aggregation same

select  nazione, sum(case when medaglia ='gold' , sport='athletics' 1 else 0 end) gold, sum(case when medaglia ='silver' , sport='athletics' 1 else 0 end) silver summertotalmedal group nazione 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -