Baselight
Loading...Loading chart...
1select p.name as player
2       , SUM(CASE WHEN mps.red_cards IS NOT NULL THEN mps.red_cards ELSE 0 END) as red_cards
3       , SUM(CASE WHEN mps.yellow_cards IS NOT NULL THEN mps.yellow_cards ELSE 0 END) as yellow_cards
4from @blt.ultimate_soccer_dataset.seasons s
5inner join @blt.ultimate_soccer_dataset.competitions c on (s.competition_id = c.competition_id)
6inner join @blt.ultimate_soccer_dataset.matches m on (m.season_id = s.season_id)
7inner join @blt.ultimate_soccer_dataset.match_player_stats mps on (mps.match_id = m.match_id)
8inner join (select distinct player_id, name from @blt.ultimate_soccer_dataset.players) p on (mps.player_id = p.player_id)
9where slug = 'premier-league' and year(s.start_date) BETWEEN 2015 and 2024
10      and m.status = 'Match Finished'
11GROUP BY ALL
12ORDER BY yellow_cards desc, red_cards desc
13limit 3
playerred_cardsyellow_cards
J. Tarkowski064
A. Doucouré260
Oriol Romeu060

Share link

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