Skip to content

Instantly share code, notes, and snippets.

@bogoreh
Created March 8, 2021 07:52
Show Gist options
  • Select an option

  • Save bogoreh/d64d3d5fa8fc039097d7ea0205ee6b87 to your computer and use it in GitHub Desktop.

Select an option

Save bogoreh/d64d3d5fa8fc039097d7ea0205ee6b87 to your computer and use it in GitHub Desktop.
/*
Challenge Box office hits database
This database contains an incomplete list of box office hits and their release year.
You're going to get results back out of the database in different ways!
*/
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 all the movies.*/
select * from movies;
/*Retrieve only the movies that were relased in the year 2000 or later, not before. Sort the results so that the earlier movies are listed first.*/
SELECT * from movies WHERE release_year > 2000 ORDER BY release_year;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment