-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpull_stats.sql
More file actions
33 lines (30 loc) · 850 Bytes
/
Copy pathpull_stats.sql
File metadata and controls
33 lines (30 loc) · 850 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
.mode box
.headers on
-- Load the JSON files
CREATE TABLE rugby_stats AS SELECT * FROM read_json_auto('rugby_stats.json');
-- Create a flattened view of points for a single season to test
WITH season_points AS (
SELECT
unnest("2021-2022".points) as point_record
FROM rugby_stats
)
SELECT
'2021-2022' as season,
point_record.pts::INTEGER as points,
point_record.person.display_name as player,
point_record.person.id as player_id
FROM season_points
ORDER BY points DESC;
-- Now let's look at tries for that season
WITH season_tries AS (
SELECT
unnest("2021-2022".tries) as try_record
FROM rugby_stats
)
SELECT
'2021-2022' as season,
try_record.tr::INTEGER as tries,
try_record.person.display_name as player,
try_record.person.id as player_id
FROM season_tries
ORDER BY tries DESC;