Baselight
Sign In

Query Result

Loading...Loading chart...
1-- Pivot to wide format: one row per week, Kane and Haaland as separate columns
2-- League matches only for a clean apples-to-apples comparison
3WITH
4  weekly AS (
5    SELECT
6      DATE_TRUNC('week', m.date::date) AS week_start,
7      ps.player_name,
8      SUM(COALESCE(ps.goals_scored, 0)) AS goals_this_week
9    FROM
10      "@blt.ultimate_soccer_dataset.match_player_stats" ps
11      JOIN "@blt.ultimate_soccer_dataset.matches" m ON ps.match_id = m.match_id
12    WHERE
13      m.status = 'Match Finished'
14      AND m.season_year = 2025
15      AND ps.player_name IN ('Harry Kane', 'Erling Haaland')
16      AND m.competition_name IN ('Bundesliga', 'Premier League')
17    GROUP BY
18      DATE_TRUNC('week', m.date::date),
19      ps.player_name
20  ),
21  pivoted AS (
22    SELECT
23      week_start,
24      SUM(
25        CASE
26          WHEN player_name = 'Harry Kane' THEN goals_this_week
27          ELSE 0
28        END
29      ) AS kane_weekly,
30      SUM(
31        CASE
32          WHEN player_name = 'Erling Haaland' THEN goals_this_week
33          ELSE 0
34        END
35      ) AS haaland_weekly
36    FROM
37      weekly
38    GROUP BY
39      week_start
40  ),
41  cumulative AS (
42    SELECT
43      week_start,
44      kane_weekly,
45      haaland_weekly,
46      SUM(kane_weekly) OVER (
47        ORDER BY
48          week_start ASC
49      ) AS kane_cumulative,
50      SUM(haaland_weekly) OVER (
51        ORDER BY
52          week_start ASC
53      ) AS haaland_cumulative
54    FROM
55      pivoted
56  )
57SELECT
58  week_start,
59  kane_weekly,
60  haaland_weekly,
61  kane_cumulative,
62  haaland_cumulative
63FROM
64  cumulative
65ORDER BY
66  week_start ASC
week_startkane_weeklyhaaland_weeklykane_cumulativehaaland_cumulative
2025-08-110202
2025-08-183032
2025-08-250133
2025-09-082255
2025-09-153186
2025-09-2222108
2025-09-2911119
2025-10-13121211
2025-10-20001211
2025-10-27021213
2025-11-03111314
2025-11-17101414
2025-11-24001414
2025-12-01311715
2025-12-08121817
2025-12-15121919
2025-12-22001919
2025-12-29001919
2026-01-05112020
2026-01-12102120
2026-01-19002120
2026-01-26102220
2026-02-02212421
2026-02-09212622
2026-02-16202822
2026-02-23203022

Share link

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