-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic_statement_exercise.sql
More file actions
64 lines (53 loc) · 1.45 KB
/
basic_statement_exercise.sql
File metadata and controls
64 lines (53 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
54
55
56
57
58
59
60
61
62
63
64
-- 1. Use the albums_db database.
SHOW DATABASES;
USE albums_db;
SELECT DATABASE();
SHOW Tables;
DESCRIBE albums;
-- 2. What is the primary key for the albums table?
DESCRIBE albums;
#The Primary Key is id column
-- 3. What does the column named 'name' represent?
#The name of an album
-- 4. What do you think the sales column represents?
# The number of album sales (How much moeney it has brought in - Millions)
-- 5. Find the name of all albums by Pink Floyd.
SELECT artist, name
FROM albums
WHERE artist = 'Pink Floyd';
# The two songs are The Dark Side of the Moon and The Wall
-- 6. What is the year Sgt. Pepper's Lonely Hearts Club Band was released?
SELECT
name,
release_date
FROM albums
WHERE name = 'Sgt. Pepper\'s Lonely Hearts Club Band';
# The release_date was 1967
-- 7. What is the genre for the album Nevermind?
SELECT artist, name, genre
FROM albums
WHERE name = 'Nevermind';
# The genre is grunge, alternative rock
-- 8. Which albums were released in the 1990s?
SELECT name, release_date
FROM albums
WHERE release_date between 1990 and 1999;
/* There are 11 albums:
The bodygaurd
Jagged Little Pill
Come on Over
Falling into You
Let's talk about love
dangerous
the immaculate collection
Titanic: music from the motion picture
Metallica
nevermind
supernatural
*/
-- 9. Which albums had less than 20 million certified sales? Rename this column as low_selling_albums.
SELECT
name as low_selling_albums,
sales
FROM albums
WHERE sales < 20.0;