-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKaraokeProject.sql
109 lines (71 loc) · 2.74 KB
/
KaraokeProject.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
CREATE TABLE songs (
id INTEGER PRIMARY KEY AUTO_INCREMENT,
title TEXT,
artist TEXT,
mood TEXT,
duration INTEGER,
released INTEGER);
INSERT INTO songs (title, artist, mood, duration, released)
VALUES ("Bohemian Rhapsody", "Queen", "epic", 60, 1975);
INSERT INTO songs (title, artist, mood, duration, released)
VALUES ("Let it go", "Idina Menzel", "epic", 227, 2013);
INSERT INTO songs (title, artist, mood, duration, released)
VALUES ("I will survive", "Gloria Gaynor", "epic", 198, 1978);
INSERT INTO songs (title, artist, mood, duration, released)
VALUES ("Twist and Shout", "The Beatles", "happy", 152, 1963);
INSERT INTO songs (title, artist, mood, duration, released)
VALUES ("La Bamba", "Ritchie Valens", "happy", 166, 1958);
INSERT INTO songs (title, artist, mood, duration, released)
VALUES ("I will always love you", "Whitney Houston", "epic", 273, 1992);
INSERT INTO songs (title, artist, mood, duration, released)
VALUES ("Sweet Caroline", "Neil Diamond", "happy", 201, 1969);
INSERT INTO songs (title, artist, mood, duration, released)
VALUES ("Call me maybe", "Carly Rae Jepsen", "happy", 193, 2011);
--Find the title names of all available songs.
SELECT title
FROM songs;
--You want to find an epic song, maybe something released after 1990.
SELECT title
FROM songs
WHERE mood = "epic" OR released > 1990;
--You want a song that is epic AND released after 1990 AND less than 240 seconds.
SELECT title
FROM songs
WHERE mood = "epic" AND released > 1990 AND duration<240;
--Youve sung your epic song, now find a list of happy songs.
SELECT title
FROM songs
WHERE mood = "happy";
--You cant quite remember the name of the artist who sings "Call me maybe"
SELECT artist
FROM songs
WHERE title = "Call me maybe";
--You want a list of all the titles where duration is in descending order.
SELECT title, duration
FROM songs
ORDER BY duration DESC;
--The Karaoke bar is clearing out all songs by Whitney Houston because she reminds him of his ex wife. Take out any WH songs
DELETE FROM songs
WHERE artist = "Whitney Houston";
--Double checking to see if delete was successful
SELECT *
FROM songs;
--Youve decided you want to change the mood of "I will survive" from epic to overplayed.
UPDATE songs
SET mood = "overplayed"
WHERE title = "I will survive";
--Double check to see if update was successful
SELECT title, mood
FROM songs;
--Find out the song with the longest duration.
SELECT MAX(duration)
FROM songs;
--result 227
SELECT title
FROM songs
WHERE duration = 227;
--result "Let it go"
--Find the avg duration of all the songs in the database
SELECT AVG(duration) AS average_duration
FROM songs;
--result 171 seconds