-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchallenge2-BoxOfficeHits .sql
More file actions
23 lines (20 loc) · 1.03 KB
/
challenge2-BoxOfficeHits .sql
File metadata and controls
23 lines (20 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/* Challenge: Box office hits database
-- Step 1
- This database contains an incomplete list of box office hits and their release year.
- In this challenge, you're going to get the results back out of the database in different ways! In this first step, just select all the movies.
*/
CREATE TABLE movies (id INTEGER PRIMARY KEY, name TEXT, release_year INTEGER);
INSERT INTO movies VALUES (1, "Avatar", 2009);
INSERT INTO movies VALUES (2, "Titanic", 1997);
INSERT INTO movies VALUES (3, "Star Wars: Episode IV - A New Hope", 1977);
INSERT INTO movies VALUES (4, "Shrek 2", 2004);
INSERT INTO movies VALUES (5, "The Lion King", 1994);
INSERT INTO movies VALUES (6, "Disney's Up", 2009);
SELECT * FROM movies;
/*
Step 2
- Now, add a second query after the first, that retrieves only the movies that were released in the year 2000 or later, not before.
- Sort the results so that the earlier movies are listed first. You should have 2 SELECT statements after this step.
*/
SELECT * FROM movies WHERE
release_year >= 2000 ORDER BY release_year ASC;