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 -

ios - MKMapView fails to load tiles with HTTP 410 error -

c# - How to utilize EF and LINQ to add filters and specify tables, columns, filters and order by dynamically -