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
Post a Comment