forked from itversity/databricks-sql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
15 Visualizations and Dashboards using Databricks SQL Warehouse.sql
66 lines (52 loc) · 1.43 KB
/
15 Visualizations and Dashboards using Databricks SQL Warehouse.sql
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
-- Basic Validations of Udemy Reviews
SELECT count(*) FROM udemy.udemy_reviews;
SELECT DISTINCT `Course Name`
FROM udemy.udemy_reviews;
SELECT * FROM udemy.udemy_reviews
WHERE `Timestamp` IS NULL;
SELECT DISTINCT `Course Name`
FROM udemy.udemy_reviews
WHERE `Timestamp` IS NOT NULL
ORDER BY 1;
SELECT DISTINCT `Rating`
FROM udemy.udemy_reviews
WHERE `Timestamp` IS NOT NULL
ORDER BY 1;
SELECT `Rating`,
COUNT(*) `Rating Count`
FROM udemy.udemy_reviews
WHERE `Timestamp` IS NOT NULL
GROUP BY 1
ORDER BY 1;
SELECT DISTINCT YEAR(`Timestamp`) AS `Review Year`
FROM udemy.udemy_reviews
WHERE `Timestamp` IS NOT NULL
ORDER BY 1;
SELECT YEAR(`Timestamp`) AS `Review Year`,
COUNT(*) AS `Rating Count`
FROM udemy.udemy_reviews
WHERE `Timestamp` IS NOT NULL
GROUP BY 1
ORDER BY 1;
SELECT `Course Name`,
COUNT(*) AS `Rating Count`
FROM udemy.udemy_reviews
WHERE `Timestamp` IS NOT NULL
GROUP BY 1
ORDER BY 1;
-- Course Review Count by Month
SELECT DATE_FORMAT(`Timestamp`, 'yyyy-MM') AS `Review Month`,
`Course Name`,
COUNT(*) AS `Review Count`
FROM udemy.udemy_reviews
WHERE `Timestamp` IS NOT NULL
AND YEAR(`Timestamp`) = {{ Review Year }}
GROUP BY 1, 2
ORDER BY 1, 2;
-- Course Review Summary
SELECT COUNT(*) AS `Total Review Count`,
COUNT(DISTINCT `Course Name`) AS `Course Count`,
COUNT_IF(`Comment` IS NOT NULL) AS `Comment Count`
FROM udemy_reviews
WHERE `Timestamp` IS NOT NULL
AND YEAR(`Timestamp`) = {{ Review Count }}