sql基础练习

题目来源:SQLBolt - Learn SQL - Introduction to SQL


目录

SQL Lesson 1: SELECT queries 101

SQL Lesson 2: Queries with constraints (Pt. 1)

SQL Lesson 3: Queries with constraints (Pt. 2)

SQL Lesson 4: Filtering and sorting Query results

SQL Review: Simple SELECT Queries

SQL Lesson 6: Multi-table queries with JOINs

SQL Lesson 7: OUTER JOINs

SQL Lesson 8: A short note on NULLs

SQL Lesson 9: Queries with expressions

SQL Lesson 10: Queries with aggregates (Pt. 1)

SQL Lesson 11: Queries with aggregates (Pt. 2)

SQL Lesson 12: Order of execution of a Query

SQL Lesson 13: Inserting rows

SQL Lesson 14: Updating rows

SQL Lesson 15: Deleting rows

SQL Lesson 16: Creating tables

SQL Lesson 17: Altering tables

SQL Lesson 18: Dropping tables


SQL Lesson 1: SELECT queries 101

Table: Movies

IdTitleDirectorYearLength_minutes
1Toy StoryJohn Lasseter199581
2A Bug's LifeJohn Lasseter199895
3Toy Story 2John Lasseter199993
4Monsters, Inc.Pete Docter200192
5Finding NemoAndrew Stanton2003107
6The IncrediblesBrad Bird2004116
7CarsJohn Lasseter2006117
8RatatouilleBrad Bird2007115
9WALL-EAndrew Stanton2008104
10UpPete Docter2009101
11Toy Story 3Lee Unkrich2010103
12Cars 2John Lasseter2011120
13BraveBrenda Chapman2012102
14Monsters UniversityDan Scanlon2013110
  1. Find the title of each film
    SELECT Title FROM movies
  2. Find the director of each film
    SELECT director FROM movies
  3. Find the title and director of each film
    SELECT title,director FROM movies
  4. Find the title and year of each film
    SELECT title , year FROM movies
  5. Find all the information about each film
    SELECT * FROM movies

SQL Lesson 2: Queries with constraints (Pt. 1)

Table: Movies

IdTitleDirectorYearLength_minutes
1Toy StoryJohn Lasseter199581
2A Bug's LifeJohn Lasseter199895
3Toy Story 2John Lasseter199993
4Monsters, Inc.Pete Docter200192
5Finding NemoAndrew Stanton2003107
6The IncrediblesBrad Bird2004116
7CarsJohn Lasseter2006117
8RatatouilleBrad Bird2007115
9WALL-EAndrew Stanton2008104
10UpPete Docter2009101
11Toy Story 3Lee Unkrich2010103
12Cars 2John Lasseter2011120
13BraveBrenda Chapman2012102
14Monsters UniversityDan Scanlon2013110

  1. Find the movie with a row id of 6
  2. Find the movies released in the years between 2000 and 2010
  3. Find the movies not released in the years between 2000 and 2010
  4. Find the first 5 Pixar movies and their release year
1.SELECT * FROM movies 
  where id = 6;

2.SELECT * FROM movies 
  where year between 2000 and 2010;

3.SELECT * FROM movies 
  where year not between 2000 and 2010;

4.SELECT title, year FROM movies 
  where year <= 2003;

SQL Lesson 3: Queries with constraints (Pt. 2)

OperatorConditionExample
=Case sensitive exact string comparison (notice the single equals)col_name = "abc"
!= or <>Case sensitive exact string inequality comparisoncol_name != "abcd"
LIKECase insensitive exact string comparisoncol_name LIKE "ABC"
NOT LIKECase insensitive exact string inequality comparisoncol_name NOT LIKE "ABCD"
%Used anywhere in a string to match a sequence of zero or more characters (only with LIKE or NOT LIKE)col_name LIKE "%AT%"
(matches "AT", "ATTIC", "CAT" or even "BATS")
_Used anywhere in a string to match a single character (only with LIKE or NOT LIKE)col_name LIKE "AN_"
(matches "AND", but not "AN")
IN (…)String exists in a listcol_name IN ("A", "B", "C")
NOT IN (…)String does not exist in a listcol_name NOT IN ("D", "E", "F")


Table: Movies

IdTitleDirectorYearLength_minutes
1Toy StoryJohn Lasseter199581
2A Bug's LifeJohn Lasseter199895
3Toy Story 2John Lasseter199993
4Monsters, Inc.Pete Docter200192
5Finding NemoAndrew Stanton2003107
6The IncrediblesBrad Bird2004116
7CarsJohn Lasseter2006117
8RatatouilleBrad Bird2007115
9WALL-EAndrew Stanton2008104
10UpPete Docter2009101
11Toy Story 3Lee Unkrich2010103
12Cars 2John Lasseter2011120
13BraveBrenda Chapman2012102
14Monsters UniversityDan Scanlon2013110
87WALL-GBrenda Chapman2042

97

  1. Find all the Toy Story movies
  2. Find all the movies directed by John Lasseter
  3. Find all the movies (and director) not directed by John Lasseter
  4. Find all the WALL-* movies

1.SELECT title, director FROM movies 
  where title LIKE "Toy Story%";

2.SELECT * FROM movies  
  WHERE director = 'John Lasseter';

3.SELECT * FROM movies 
  WHERE director != 'John Lasseter';

4.SELECT * FROM movies 
  WHERE title LIKE "WALL-_";

SQL Lesson 4: Filtering and sorting Query results

SELECT column, another_column, …
FROM mytable
WHERE condition(s)
ORDER BY column ASC/DESC
LIMIT num_limit OFFSET num_offset;

Table: Movies

IdTitleDirectorYearLength_minutes
1WALL-EAndrew Stanton2008104
2CarsJohn Lasseter2006117
3BraveBrenda Chapman2012102
4The IncrediblesBrad Bird2004116
5Cars 2John Lasseter2011120
6Toy Story 3Lee Unkrich2010103
7A Bug's LifeJohn Lasseter199895
8RatatouilleBrad Bird2007115
9Monsters UniversityDan Scanlon2013110
10Toy StoryJohn Lasseter199581
11Finding NemoAndrew Stanton2003107
12Toy Story 2John Lasseter199993
13UpPete Docter2009101
14Monsters, Inc.Pete Docter200192

  1. List all directors of Pixar movies (alphabetically), without duplicates
  2. List the last four Pixar movies released (ordered from most recent to least)
  3. List the first five Pixar movies sorted alphabetically
  4. List the next five Pixar movies sorted alphabetically
1.SELECT distinct director FROM movies 
  order by director;

2.SELECT title 
  FROM movies 
  ORDER BY year desc 
  limit 4

3.select * from movies 
  order by title 
  limit 5

4.select * from movies 
  order by title 
  limit 5 offset 5

SQL Review: Simple SELECT Queries

Table: North_american_cities

CityCountryPopulationLatitudeLongitude
GuadalajaraMexico150080020.659699-103.349609
TorontoCanada279506043.653226-79.383184
HoustonUnited States219591429.760427-95.369803
New YorkUnited States840583740.712784-74.005941
PhiladelphiaUnited States155316539.952584-75.165222
HavanaCuba210614623.05407-82.345189
Mexico CityMexico855550019.432608-99.133208
PhoenixUnited States151336733.448377-112.074037
Los AngelesUnited States388430734.052234-118.243685
Ecatepec de MorelosMexico174200019.601841-99.050674
MontrealCanada171776745.501689-73.567256
ChicagoUnited States271878241.878114-87.629798

  1. List all the Canadian cities and their populations
  2. Order all the cities in the United States by their latitude from north to south
  3. List all the cities west of Chicago, ordered from west to east
  4. List the two largest cities in Mexico (by population)
  5. List the third and fourth largest cities (by population) in the United States and their population
1.select city , population from North_american_cities
  where country = "Canada"

2.select city from North_american_cities
  where country = 'United States'
  order by Latitude desc

3.SELECT city, longitude FROM north_american_cities
  WHERE longitude < -87.629798
  ORDER BY longitude

4.select * from North_american_cities
  where country = "Mexico"
  order by population desc
  limit 2

5.select * from North_american_cities
  where country = "United States"
  order by population desc
  limit 2 offset 2

SQL Lesson 6: Multi-table queries with JOINs

Select query with INNER JOIN on multiple tables
SELECT column, another_table_column, …
FROM mytable
INNER JOIN another_table 
    ON mytable.id = another_table.id
WHERE condition(s)
ORDER BY column, … ASC/DESC
LIMIT num_limit OFFSET num_offset;

Table: Movies (Read-Only)

IdTitleDirectorYearLength_minutes
1Toy StoryJohn Lasseter199581
2A Bug's LifeJohn Lasseter199895
3Toy Story 2John Lasseter199993
4Monsters, Inc.Pete Docter200192
5Finding NemoAndrew Stanton2003107
6The IncrediblesBrad Bird2004116
7CarsJohn Lasseter2006117
8RatatouilleBrad Bird2007115
9WALL-EAndrew Stanton2008104
10UpPete Docter2009101
11Toy Story 3Lee Unkrich2010103
12Cars 2John Lasseter2011120
13BraveBrenda Chapman2012102
14Monsters UniversityDan Scanlon2013110

Table: Boxoffice (Read-Only)

Movie_idRatingDomestic_salesInternational_sales
58.2380843261555900000
147.4268492764475066843
88206445654417277164
126.4191452396368400000
37.9245852179239163000
68261441092370001000
98.5223808164297503696
118.4415004880648167031
18.3191796233170162503
77.2244082982217900167
108.3293004164438338580
48.1289916256272900000
27.2162798565200600000
137.2237283207301700000
  1. Find the domestic and international sales for each movie
  2. Show the sales numbers for each movie that did better internationally rather than domestically
  3. List all the movies by their ratings in descending order
1.select Title , Domestic_sales , International_sales 
  from Movies
  inner join Boxoffice 
  on Movies.Id = Boxoffice.Movie_id

2.select Title , Domestic_sales , International_sales 
  from Movies
  inner join Boxoffice 
  on Movies.Id = Boxoffice.Movie_id
  where International_sales > Domestic_sales

3.select Title , rating 
  from Movies
  inner join Boxoffice 
  on Movies.Id = Boxoffice.Movie_id
  order by rating desc

SQL Lesson 7: OUTER JOINs

Table: Buildings (Read-Only)

Building_nameCapacity
1e24
1w32
2e16
2w20

Table: Employees (Read-Only)

RoleNameBuildingYears_employed
EngineerBecky A.1e4
EngineerDan B.1e2
EngineerSharon F.1e6
EngineerDan M.1e4
EngineerMalcom S.1e1
ArtistTylar S.2w2
ArtistSherman D.2w8
ArtistJakob J.2w6
ArtistLillia A.2w7
ArtistBrandon J.2w7
ManagerScott K.1e9
ManagerShirlee M.1e3
ManagerDaria O.2w6
  1. Find the list of all buildings that have employees
  2. Find the list of all buildings and their capacity
  3. List all buildings and the distinct employee roles in each building (including empty buildings)
1.SELECT DISTINCT building 
  FROM employees

2.SELECT * FROM buildings

3.SELECT DISTINCT building_name, role 
  FROM buildings 
  LEFT JOIN employees
  ON building_name = building;

SQL Lesson 8: A short note on NULLs

Table: Buildings (Read-Only)

Building_nameCapacity
1e24
1w32
2e16
2w20

Table: Employees (Read-Only)

RoleNameBuildingYears_employed
EngineerBecky A.1e4
EngineerDan B.1e2
EngineerSharon F.1e6
EngineerDan M.1e4
EngineerMalcom S.1e1
ArtistTylar S.2w2
ArtistSherman D.2w8
ArtistJakob J.2w6
ArtistLillia A.2w7
ArtistBrandon J.2w7
ManagerScott K.1e9
ManagerShirlee M.1e3
ManagerDaria O.2w6
EngineerYancy I.0
ArtistOliver P.0
  1. Find the name and role of all employees who have not been assigned to a building
  2. Find the names of the buildings that hold no employees
1.SELECT name , role 
  FROM employees 
  where building is null

2.SELECT DISTINCT building_name
  FROM buildings 
  LEFT JOIN employees
    ON building_name = building
  WHERE role IS NULL;

SQL Lesson 9: Queries with expressions

Table: Movies (Read-Only)

IdTitleDirectorYearLength_minutes
1Toy StoryJohn Lasseter199581
2A Bug's LifeJohn Lasseter199895
3Toy Story 2John Lasseter199993
4Monsters, Inc.Pete Docter200192
5Finding NemoAndrew Stanton2003107
6The IncrediblesBrad Bird2004116
7CarsJohn Lasseter2006117
8RatatouilleBrad Bird2007115
9WALL-EAndrew Stanton2008104
10UpPete Docter2009101
11Toy Story 3Lee Unkrich2010103
12Cars 2John Lasseter2011120
13BraveBrenda Chapman2012102
14Monsters UniversityDan Scanlon2013110

Table: Boxoffice (Read-Only)

Movie_idRatingDomestic_salesInternational_sales
58.2380843261555900000
147.4268492764475066843
88206445654417277164
126.4191452396368400000
37.9245852179239163000
68261441092370001000
98.5223808164297503696
118.4415004880648167031
18.3191796233170162503
77.2244082982217900167
108.3293004164438338580
48.1289916256272900000
27.2162798565200600000
137.2237283207301700000
  1. List all movies and their combined sales in millions of dollars
  2. List all movies and their ratings in percent
  3. List all movies that were released on even number years
1.SELECT Title ,(Domestic_sales+International_sales)/1000000 
    as total_sales 
  FROM movies    
  join Boxoffice 
    on Movies.Id =Boxoffice.Movie_id

2.SELECT Title ,rating*10  as rating_persent 
  FROM movies    
  join Boxoffice 
    on Movies.Id =Boxoffice.Movie_id

3.SELECT Title ,year 
  FROM movies    
  join Boxoffice 
    on Movies.Id =Boxoffice.Movie_id
  where year%2 = 0

SQL Lesson 10: Queries with aggregates (Pt. 1)

FunctionDescription
COUNT(*)COUNT(column)A common function used to counts the number of rows in the group if no column name is specified. Otherwise, count the number of rows in the group with non-NULL values in the specified column.
MIN(column)Finds the smallest numerical value in the specified column for all rows in the group.
MAX(column)Finds the largest numerical value in the specified column for all rows in the group.
AVG(column)Finds the average numerical value in the specified column for all rows in the group.
SUM(column)Finds the sum of all numerical values in the specified column for the rows in the group.

Table: Employees

RoleNameBuildingYears_employed
EngineerBecky A.1e4
EngineerDan B.1e2
EngineerSharon F.1e6
EngineerDan M.1e4
EngineerMalcom S.1e1
ArtistTylar S.2w2
ArtistSherman D.2w8
ArtistJakob J.2w6
ArtistLillia A.2w7
ArtistBrandon J.2w7
ManagerScott K.1e9
ManagerShirlee M.1e3
ManagerDaria O.2w6
  1. Find the longest time that an employee has been at the studio
  2. For each role, find the average number of years employed by employees in that role
  3. Find the total number of employee years worked in each building
1.SELECT name , max(Years_employed) 
  FROM employees

2.select role , avg(Years_employed) as avg_years 
  from employees
  group by role

3.select building , sum(Years_employed)   
  from employees
  group by building

SQL Lesson 11: Queries with aggregates (Pt. 2)

Table: Employees

RoleNameBuildingYears_employed
EngineerBecky A.1e4
EngineerDan B.1e2
EngineerSharon F.1e6
EngineerDan M.1e4
EngineerMalcom S.1e1
ArtistTylar S.2w2
ArtistSherman D.2w8
ArtistJakob J.2w6
ArtistLillia A.2w7
ArtistBrandon J.2w7
ManagerScott K.1e9
ManagerShirlee M.1e3
ManagerDaria O.2w6
  1. Find the number of Artists in the studio (without a HAVING clause)
  2. Find the number of Employees of each role in the studio
  3. Find the total number of years employed by all Engineers
1.select role , count(*) as num
  from employees
  where role = "Artist"

2.select role , count(*) 
  from employees
  group by role

3.SELECT role, SUM(years_employed)
  FROM employees
  GROUP BY role
  HAVING role = "Engineer";

SQL Lesson 12: Order of execution of a Query

Table: Movies (Read-Only)

IdTitleDirectorYearLength_minutes
1Toy StoryJohn Lasseter199581
2A Bug's LifeJohn Lasseter199895
3Toy Story 2John Lasseter199993
4Monsters, Inc.Pete Docter200192
5Finding NemoAndrew Stanton2003107
6The IncrediblesBrad Bird2004116
7CarsJohn Lasseter2006117
8RatatouilleBrad Bird2007115
9WALL-EAndrew Stanton2008104
10UpPete Docter2009101
11Toy Story 3Lee Unkrich2010103
12Cars 2John Lasseter2011120
13BraveBrenda Chapman2012102
14Monsters UniversityDan Scanlon2013110

Table: Boxoffice (Read-Only)

Movie_idRatingDomestic_salesInternational_sales
58.2380843261555900000
147.4268492764475066843
88206445654417277164
126.4191452396368400000
37.9245852179239163000
68261441092370001000
98.5223808164297503696
118.4415004880648167031
18.3191796233170162503
77.2244082982217900167
108.3293004164438338580
48.1289916256272900000
27.2162798565200600000
137.2237283207301700000
  1. Find the number of movies each director has directed
  2. Find the total domestic and international sales that can be attributed to each director
1.SELECT director , count(*) 
  FROM movies
  group by director

2.select director , sum(Domestic_sales+International_sales) as total_sales 
  from movies
  join Boxoffice 
    on Movies.Id = Boxoffice.Movie_id
  group by director

SQL Lesson 13: Inserting rows

INSERT INTO mytable
(column, another_column, …)
VALUES (value_or_expr, another_value_or_expr, …),
      (value_or_expr_2, another_value_or_expr_2, …),
      …;

Table: Movies (Read-Only)

IdTitleDirectorYearLength_minutes
1Toy StoryJohn Lasseter199581
2A Bug's LifeJohn Lasseter199895
3Toy Story 2John Lasseter199993

Table: Boxoffice (Read-Only)

Movie_idRatingDomestic_salesInternational_sales
37.9245852179239163000
18.3191796233170162503
27.2162798565200600000
  1. Add the studio's new production, Toy Story 4 to the list of movies (you can use any director)
  2. Toy Story 4 has been released to critical acclaim! It had a rating of 8.7, and made 340 million domestically and 270 million internationally. Add the record to the BoxOffice table.
1.insert into movies
  (Title,Director)
  values('Toy Story 4',"John Lasseter")

2.INSERT INTO boxoffice 
  VALUES (4, 8.7, 340000000, 270000000)


SQL Lesson 14: Updating rows

Update statement with values
UPDATE mytable
SET column = value_or_expr, 
    other_column = another_value_or_expr, 
    …
WHERE condition;


Table: Movies

IdTitleDirectorYearLength_minutes
1Toy StoryJohn Lasseter199581
2A Bug's LifeEl Directore199895
3Toy Story 2John Lasseter189993
4Monsters, Inc.Pete Docter200192
5Finding NemoAndrew Stanton2003107
6The IncrediblesBrad Bird2004116
7CarsJohn Lasseter2006117
8RatatouilleBrad Bird2007115
9WALL-EAndrew Stanton2008104
10UpPete Docter2009101
11Toy Story 8El Directore2010103
12Cars 2John Lasseter2011120
13BraveBrenda Chapman2012102
14Monsters UniversityDan Scanlon2013110
  1. The director for A Bug's Life is incorrect, it was actually directed by John Lasseter
  2. The year that Toy Story 2 was released is incorrect, it was actually released in 1999
  3. Both the title and director for Toy Story 8 is incorrect! The title should be "Toy Story 3" and it was directed by Lee Unkrich
1.UPDATE movies
  SET director = "John Lasseter"
  WHERE id = 2

2.update movies
  set year=1999
  where Title="Toy Story 2"

3.update movies
  set title = "Toy Story 3", director = "Lee Unkrich"
  where id = 11


SQL Lesson 15: Deleting rows

DELETE FROM mytable
WHERE condition;

Table: Movies

IdTitleDirectorYearLength_minutes
1Toy StoryJohn Lasseter199581
2A Bug's LifeJohn Lasseter199895
3Toy Story 2John Lasseter199993
4Monsters, Inc.Pete Docter200192
5Finding NemoAndrew Stanton2003107
6The IncrediblesBrad Bird2004116
7CarsJohn Lasseter2006117
8RatatouilleBrad Bird2007115
9WALL-EAndrew Stanton2008104
10UpPete Docter2009101
11Toy Story 3Lee Unkrich2010103
12Cars 2John Lasseter2011120
13BraveBrenda Chapman2012102
14Monsters UniversityDan Scanlon2013110
  1. This database is getting too big, lets remove all movies that were released before 2005.
  2. Andrew Stanton has also left the studio, so please remove all movies directed by him.
1.delete from movies 
  where year < 2005

2.delete from movies
  where director = "Andrew Stanton";


SQL Lesson 16: Creating tables


Table data types
Data typeDescription
INTEGERBOOLEANThe integer datatypes can store whole integer values like the count of a number or an age. In some implementations, the boolean value is just represented as an integer value of just 0 or 1.
FLOATDOUBLEREALThe floating point datatypes can store more precise numerical data like measurements or fractional values. Different types can be used depending on the floating point precision required for that value.
CHARACTER(num_chars)VARCHAR(num_chars)TEXT

The text based datatypes can store strings and text in all sorts of locales. The distinction between the various types generally amount to underlaying efficiency of the database when working with these columns.

Both the CHARACTER and VARCHAR (variable character) types are specified with the max number of characters that they can store (longer values may be truncated), so can be more efficient to store and query with big tables.

DATEDATETIMESQL can also store date and time stamps to keep track of time series and event data. They can be tricky to work with especially when manipulating data across timezones.
BLOBFinally, SQL can store binary data in blobs right in the database. These values are often opaque to the database, so you usually have to store them with the right metadata to requery them.

Table constraints
ConstraintDescription
PRIMARY KEYThis means that the values in this column are unique, and each value can be used to identify a single row in this table.
AUTOINCREMENTFor integer values, this means that the value is automatically filled in and incremented with each row insertion. Not supported in all databases.
UNIQUEThis means that the values in this column have to be unique, so you can't insert another row with the same value in this column as another row in the table. Differs from the `PRIMARY KEY` in that it doesn't have to be a key for a row in the table.
NOT NULLThis means that the inserted value can not be `NULL`.
CHECK (expression)This allows you to run a more complex expression to test whether the values inserted are valid. For example, you can check that values are positive, or greater than a specific size, or start with a certain prefix, etc.
FOREIGN KEYThis is a consistency check which ensures that each value in this column corresponds to another value in a column in another table.

For example, if there are two tables, one listing all Employees by ID, and another listing their payroll information, the `FOREIGN KEY` can ensure that every row in the payroll table corresponds to a valid employee in the master Employee list.

CREATE TABLE movies (
    id INTEGER PRIMARY KEY,
    title TEXT,
    director TEXT,
    year INTEGER, 
    length_minutes INTEGER
);

  1. Create a new table named Database with the following columns:

    – Name A string (text) describing the name of the database
    – Version A number (floating point) of the latest version of this database
    – Download_count An integer count of the number of times this database was downloaded

    This table has no constraints.
CREATE TABLE Database (
    Name TEXT,
    Version FLOAT,
    Download_count INTEGER
);

SQL Lesson 17: Altering tables

Adding columns

ALTER TABLE mytable
ADD column DataType OptionalTableConstraint 
    DEFAULT default_value;
---------------------------------------------------
Removing columns

ALTER TABLE mytable
DROP column_to_be_deleted;
----------------------------------------------------
Renaming the table

ALTER TABLE mytable
RENAME TO new_table_name;

Table: Movies

IdTitleDirectorYearLength_minutes
1Toy StoryJohn Lasseter199581
2A Bug's LifeJohn Lasseter199895
3Toy Story 2John Lasseter199993
4Monsters, Inc.Pete Docter200192
5Finding NemoAndrew Stanton2003107
6The IncrediblesBrad Bird2004116
7CarsJohn Lasseter2006117
8RatatouilleBrad Bird2007115
9WALL-EAndrew Stanton2008104
10UpPete Docter2009101
11Toy Story 3Lee Unkrich2010103
12Cars 2John Lasseter2011120
13BraveBrenda Chapman2012102
14Monsters UniversityDan Scanlon2013110
  1. Add a column named Aspect_ratio with a FLOAT data type to store the aspect-ratio each movie was released in.
  2. Add another column named Language with a TEXT data type to store the language that the movie was released in. Ensure that the default for this language is English.

1.alter table Movies
  add Aspect_ratio 
  default float

2.alter table Movies
  add COLUMN Language TEXT DEFAULT "English"

SQL Lesson 18: Dropping tables

DROP TABLE IF EXISTS mytable;

Table: Movies (Read-Only)

IdTitleDirectorYearLength_minutes
1Toy StoryJohn Lasseter199581
2A Bug's LifeJohn Lasseter199895
3Toy Story 2John Lasseter199993
4Monsters, Inc.Pete Docter200192
5Finding NemoAndrew Stanton2003107
6The IncrediblesBrad Bird2004116
7CarsJohn Lasseter2006117
8RatatouilleBrad Bird2007115
9WALL-EAndrew Stanton2008104
10UpPete Docter2009101
11Toy Story 3Lee Unkrich2010103
12Cars 2John Lasseter2011120
13BraveBrenda Chapman2012102
14Monsters UniversityDan Scanlon2013110

Table: Boxoffice (Read-Only)

Movie_idRatingDomestic_salesInternational_sales
58.2380843261555900000
147.4268492764475066843
88206445654417277164
126.4191452396368400000
37.9245852179239163000
68261441092370001000
98.5223808164297503696
118.4415004880648167031
18.3191796233170162503
77.2244082982217900167
108.3293004164438338580
48.1289916256272900000
27.2162798565200600000
137.2237283207301700000

  1. We've sadly reached the end of our lessons, lets clean up by removing the Movies table
  2. And drop the BoxOffice table as well
1.drop table IF EXISTS Movies

2.drop table IF EXISTS BoxOffice

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值