Baselight
select p.name as player
       , SUM(CASE WHEN mps.goals_scored IS NOT NULL THEN mps.goals_scored ELSE 0 END) as goals_scored
       , SUM(CASE WHEN mps.goals_assists IS NOT NULL THEN mps.goals_assists ELSE 0 END) as goals_assists
       , SUM(CASE WHEN mps.yellow_cards IS NOT NULL THEN mps.yellow_cards ELSE 0 END) as yellow_cards
       , SUM(CASE WHEN mps.red_cards IS NOT NULL THEN mps.red_cards ELSE 0 END) as red_cards
from @blt.ultimate_soccer_dataset.seasons s
inner join @blt.ultimate_soccer_dataset.competitions c on (s.competition_id = c.competition_id)
inner join @blt.ultimate_soccer_dataset.matches m on (m.season_id = s.season_id)
inner join @blt.ultimate_soccer_dataset.match_player_stats mps on (mps.match_id = m.match_id)
inner join @blt.ultimate_soccer_dataset.players p on (mps.player_id = p.player_id)
where slug = 'premier-league' and year(s.start_date) >= 2015 and m.status = 'Match Finished'
GROUP BY ALL
ORDER BY goals_scored desc, goals_assists desc, yellow_cards asc, red_cards asc
limit 10
playergoals_scoredgoals_assistsyellow_cardsred_cards
H. Kane18942340
Mohamed Salah1858790
J. Vardy14040263
Son Heung-Min12771103
S. Agüero10623111
R. Sterling10551381
S. Mané10135263
C. Wood901160
M. Rashford8942241
C. Wilson8923270

Share link

Anyone who has the link will be able to view this.