-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemp_table_3_4.sql
66 lines (63 loc) · 1.27 KB
/
temp_table_3_4.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
INSERT INTO temp_table_3(
id_track
,name
,popularity
,duration_min
,explicit
,artists
,id_artists
,release_date
,release_year
,calculated_release_year
,danceability
,energy
,_key
,loudness
,mode
,speechiness
,acousticness
,instrumentalness
,liveness
,valence
,tempo
,time_signature
,artist_id
,artist_name
,artist_followers
,artist_genres
,artist_popularity
)
SELECT
id_track
,name
,popularity
,duration_min
,explicit
,artists
,id_artists
,release_date
,release_year
,CASE
WHEN CHAR_LENGTH( SUBSTRING_INDEX(REPLACE(release_date,'-','/'),'/',1)) < 4 THEN SUBSTR(REPLACE(release_date,'-','/'),'-4',4)
ELSE SUBSTR(REPLACE(release_date,'-','/'),'1',4)
END AS calculated_release_year
,danceability
,energy
,_key
,loudness
,mode
,speechiness
,acousticness
,instrumentalness
,liveness
,valence
,tempo
,time_signature
,artist_id_4 AS artist_id
,artist_4 AS artist_name
,NULL AS artist_followers
,NULL AS artist_genres
,NULL AS artist_popularity
FROM temp_table_2
WHERE artist_id_4 IS NOT NULL
LIMIT 0,50000