Loading...Loading chart...
1select m.referee_name
2 , sum(case when m_stats.type = 'Yellow Cards' THEN m_stats.value END) as yellow_cards
3 , sum(case when m_stats.type = 'Red Cards' THEN m_stats.value END) as red_cards
4 , sum(case when m_stats.type = 'Fouls' THEN m_stats.value END) as fouls
5from @blt.ultimate_soccer_dataset.matches m
6 INNER JOIN @blt.ultimate_soccer_dataset.match_stats m_stats ON (m.match_id = m_stats.match_id)
7 INNER JOIN @blt.ultimate_soccer_dataset.teams teams ON (m_stats.team_id = teams.team_id)
8 INNER JOIN @blt.ultimate_soccer_dataset.seasons s ON (m.season_id = s.season_id)
9 INNER JOIN @blt.ultimate_soccer_dataset.competitions c ON (s.competition_id = c.competition_id)
10where referee_name <> 'None'
11group by 1
12order by yellow_cards desc, red_cards desc, fouls desc
13limit 5