-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSpotify.sql
72 lines (50 loc) · 1.69 KB
/
Spotify.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
67
68
69
70
71
72
use SuperStoreOrders
Select * from Songs
#Identify the most popular artists and songs based on the popularity column
select artist, song, popularity
from Songs
where artist != 'NULL'
order by popularity desc
#Analyze the audio features such as danceability, energy, loudness, speechiness, etc
SELECT AVG(danceability) AS avg_danceability, AVG(energy) AS avg_energy, AVG(loudness) AS avg_loudness
FROM Songs;
#Explore the distribution of songs across different years using the year column.
select year, COUNT(*) as songs_count
from Songs
group by year
order by year
#Examine the distribution of songs across different genres.
Select genre, COUNT(*) as songs_count
from Songs
Group by genre
order by songs_count desc
#Investigate the presence of explicit content using the explicit column.
SELECT explicit, COUNT(*) AS song_count
FROM Songs
GROUP BY explicit;
#Track Count by year and Genre
SELECT year, genre, COUNT(*) AS track_count
from Songs
group by year, genre
order by track_count desc
#Average Tempo by year
Select year, AVG(tempo) as avg_tempo
from Songs
group by year
order by year
#Top Genres by Popularity
Select genre, AVG(popularity) as avg_popularity
from Songs
Group by genre
order by avg_popularity desc
#Songs Duration Distribution
Select genre, MIN(duration_ms) as min_duration, MAX(duration_ms) as max_duration,
AVG(duration_ms) as avg_duration
from Songs
Group by genre
#Percentage of Explicit Songs by Genre
SELECT genre, COUNT(*) AS total_songs, SUM(explicit) AS explicit_songs,
ROUND((SUM(explicit) * 100.0) / COUNT(*), 2) AS explicit_percentage
FROM Songs
GROUP BY genre
ORDER BY explicit_percentage DESC;