-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSandyDataAnalysisSQLite.sql
More file actions
67 lines (54 loc) · 2.08 KB
/
SandyDataAnalysisSQLite.sql
File metadata and controls
67 lines (54 loc) · 2.08 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
-- These are additional questions not in the original guided SQL project
/*For the preliminary database creation and table creation, as well as
preliminary data exploration, e.g., null values, missing values,
number of unique apps, see the GuidedSQL file.
*/
**DEEPER DATA ANALYSIS**
-- What are all the apps with 5.0 user_ratings for each of the top 5 prime_genres
-- with higher average ratings. Recall that the top prime_genres with high
-- average ratings are: productivity, music, photo & video, business, health & fitness
-- free apps with user rating = 5 in top 5 categories
Select prime_genre, track_name, user_rating, price
From AppleStore
Where prime_genre in ('Health & Fitness', 'Business', 'Photo & Video', 'Music', 'Productivity')
and user_rating = 5
and price = 0
Order By prime_genre
-- paid apps with user rating = 5 in top 5 categories
Select prime_genre, track_name, user_rating, price
From AppleStore
Where prime_genre in ('Health & Fitness', 'Business', 'Photo & Video', 'Music', 'Productivity')
and user_rating = 5
and price > 0
Order By prime_genre, price DESC
-- apps with user rating = 5 in 'Games' category
Select prime_genre, track_name, user_rating, price
From AppleStore
Where prime_genre in ('Games')
and user_rating = 5
Order By price DESC
-- apps with prices greater than 10
Select prime_genre, track_name, price
From AppleStore
Where price > 10
and prime_genre in ('Health & Fitness', 'Business', 'Photo & Video', 'Music', 'Productivity')
Order By prime_genre, price DESC
-- games that have prices greater than 10 and their cont_rating
Select prime_genre, track_name, price, cont_rating
From AppleStore
Where price > 10
and prime_genre = 'Games'
Order By price DESC, cont_rating DESC
-- games that are the most expensive and have a rating of 5
With CTE_Ranking as
(
Select prime_genre, track_name, user_rating, price,
Rank() OVER (PARTITION BY prime_genre ORDER BY price DESC) AS Ranking
From AppleStore
Where user_rating = 5
and price > 0
)
SELECT *
FROM CTE_Ranking
Where Ranking < 5
Order By prime_genre, price DESC