Loading...Loading chart...
1select CASE
2 WHEN goals_scored = 0 THEN '0'
3 WHEN goals_scored = 1 THEN '1'
4 WHEN goals_scored = 2 THEN '2'
5 ELSE '3+'
6 END AS goals_bucket, count(match_id) as nr_matches
7from
8(select m.match_id, SUM(CASE WHEN mps.goals_scored IS NOT NULL THEN mps.goals_scored ELSE 0 END) as goals_scored
9 , SUM(CASE WHEN mps.goals_assists IS NOT NULL THEN mps.goals_assists ELSE 0 END) as goals_assists
10 , COUNT(distinct m.match_id) as total_matches
11from @blt.ultimate_soccer_dataset.seasons s
12inner join @blt.ultimate_soccer_dataset.competitions c on (s.competition_id = c.competition_id)
13inner join @blt.ultimate_soccer_dataset.matches m on (m.season_id = s.season_id)
14left outer join @blt.ultimate_soccer_dataset.match_player_stats mps on (mps.match_id = m.match_id)
15where slug = 'premier-league' and year(s.start_date) BETWEEN 2015 and 2024
16 and m.status = 'Match Finished'
17group by all
18)
19group by all
20order by nr_matches desc