-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanalytics.sql
More file actions
93 lines (85 loc) · 2.57 KB
/
analytics.sql
File metadata and controls
93 lines (85 loc) · 2.57 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
--- BigQuery
with df as (SELECT
EXTRACT(MONTH FROM fr.released)AS `Month`,
FORMAT_DATE('%B', fr.released)AS `Month Name`,
count(fr._dlt_id) AS `Count`
FROM rawg_fctTable.fctRawg fr
GROUP BY EXTRACT(MONTH FROM fr.released),
FORMAT_DATE('%B', fr.released))
select * from df
order by df.`Month` asc
SELECT
'PC' AS `Platform`,
count(CASE WHEN LOWER(fr.platform_name) LIKE '%pc%' THEN _dlt_id END) AS `Count`
FROM rawg_fctTable.fctRawg fr
UNION ALL
SELECT
'Linux',
count(CASE WHEN LOWER(fr.platform_name) LIKE '%linux%' THEN _dlt_id END) AS `Count`
FROM rawg_fctTable.fctRawg fr
UNION ALL
SELECT
'macOS',
count(CASE WHEN LOWER(fr.platform_name) LIKE '%macos%' THEN _dlt_id END) AS `macOS`
FROM rawg_fctTable.fctRawg fr
UNION ALL
SELECT
'PS5',
count(CASE WHEN LOWER(fr.platform_name) LIKE '%playStation 5%' THEN _dlt_id END) AS `PS5`
FROM rawg_fctTable.fctRawg fr
UNION ALL
SELECT
'Nintendo',
count(CASE WHEN LOWER(fr.platform_name) LIKE '%nintendo switch%' THEN _dlt_id END) AS `Nintendo`
FROM rawg_fctTable.fctRawg fr
UNION ALL
SELECT
'XBox',
count(CASE WHEN LOWER(fr.platform_name) LIKE '%xbox%' THEN _dlt_id END) AS `XBOX`
FROM rawg_fctTable.fctRawg fr
UNION ALL
SELECT
'Android',
count(CASE WHEN LOWER(fr.platform_name) LIKE '%android%' THEN _dlt_id END) AS `Android`
FROM rawg_fctTable.fctRawg fr
--- Postgres
SELECT
'PC' AS "Platform",
count(CASE WHEN fr.platform_name ILIKE '%PC%' THEN _dlt_id END) AS "Count"
FROM rawg."rawg_fctTable"."fctRawg" fr
UNION ALL
SELECT
'Linux',
count(CASE WHEN fr.platform_name ILIKE '%Linux%' THEN _dlt_id END) AS "Count"
FROM rawg."rawg_fctTable"."fctRawg" fr
UNION ALL
SELECT
'macOS',
count(CASE WHEN fr.platform_name ILIKE '%macOS%' THEN _dlt_id END) AS "macOS"
FROM rawg."rawg_fctTable"."fctRawg" fr
UNION ALL
SELECT
'PS5',
count(CASE WHEN fr.platform_name ILIKE '%PlayStation 5%' THEN _dlt_id END) AS "PS5"
FROM rawg."rawg_fctTable"."fctRawg" fr
UNION ALL
SELECT
'Nintendo',
count(CASE WHEN fr.platform_name ILIKE '%Nintendo Switch%' THEN _dlt_id END) AS "Nintendo"
FROM rawg."rawg_fctTable"."fctRawg" fr
UNION ALL
SELECT
'XBox',
count(CASE WHEN fr.platform_name ILIKE '%Xbox%' THEN _dlt_id END) AS "XBOX"
FROM rawg."rawg_fctTable"."fctRawg" fr
UNION ALL
SELECT
'Android',
count(CASE WHEN fr.platform_name ILIKE '%Android%' THEN _dlt_id END) AS "Android"
FROM rawg."rawg_fctTable"."fctRawg" fr
SELECT
EXTRACT(MONTH FROM fr.released)AS "Month",
TO_CHAR(fr.released, 'Month')AS "Month Name",
count(fr._dlt_id) AS "Count"
FROM rawg."rawg_fctTable"."fctRawg" fr
GROUP BY EXTRACT(MONTH FROM fr.released),TO_CHAR(fr.released, 'Month')