-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSpotify Analysis
More file actions
53 lines (46 loc) · 1.45 KB
/
Copy pathSpotify Analysis
File metadata and controls
53 lines (46 loc) · 1.45 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
#For this project, I downloaded and used Spotify data
#I then created a table
#After I created the table, I performed analysis on the Spotify data
#Creating the table:
CREATE TABLE BIT_DB.Spotifydata (
id integer PRIMARY KEY,
artist_name varchar NOT NULL,
track_name varchar NOT NULL,
track_id varchar NOT NULL,
popularity integer NOT NULL,
danceability decimal(4,3) NOT NULL,
energy decimal(4,3) NOT NULL,
key integer NOT NULL,
loudness decimal(5,3) NOT NULL,
mode integer NOT NULL,
speechiness decimal(5,4) NOT NULL,
acousticness decimal(6,5) NOT NULL,
instrumentalness text NOT NULL,
liveness decimal(5,4) NOT NULL,
valence decimal(4,3) NOT NULL,
tempo decimal(6,3) NOT NULL,
duration_ms integer NOT NULL,
time_signature integer NOT NULL
)
#Then I inserted the Spotify Data .csv into the table.
#Next, I explored the data using the following SQL.
--Finding the top 10 artists based on popularity
SELECT artist_name, AVG(popularity) AS avg_popularity
FROM BIT_DB.Spotifydata
GROUP BY artist_name
ORDER BY AVG(popularity) DESC
LIMIT 10;
--Finding the top 10 songs based on popularity
SELECT artist_name, track_name, popularity
FROM BIT_DB.Spotifydata
ORDER BY popularity DESC
LIMIT 10;
--Artist with the longest song
SELECT artist_name, track_name, duration_ms
FROM BIT_DB.Spotifydata
ORDER BY duration_ms DESC
LIMIT 1;
--The average danceability of tracks with popularity above 80
SELECT AVG(danceability) AS avg_danceability
FROM BIT_DB.Spotifydata
WHERE popularity > 80;