db_id
stringclasses
146 values
question
stringlengths
3
224
sql
stringlengths
18
577
database_schema
stringclasses
146 values
icfp_1
Retrieve the country that has published the most papers.
SELECT t1.country FROM inst AS t1 JOIN authorship AS t2 ON t1.instid = t2.instid JOIN papers AS t3 ON t2.paperid = t3.paperid GROUP BY t1.country ORDER BY count(*) DESC LIMIT 1
CREATE TABLE Inst ( instID INTEGER, name TEXT, country TEXT, -- the home country of the institution (this is obviously an impoverished model) PRIMARY KEY (instID) ) 3 rows from Inst table: instID name country 1000 University of Oxford UK 1010 Northeastern University USA 1020 Indiana University USA CREATE TABLE Authors ( authID INTEGER, lname TEXT, fname TEXT, PRIMARY KEY (authID) ) 3 rows from Authors table: authID lname fname 50 Gibbons Jeremy 51 Hinze Ralf 52 James Daniel W. H. CREATE TABLE Papers ( paperID INTEGER, title TEXT, PRIMARY KEY (paperID) ) 3 rows from Papers table: paperID title 200 Just do it: Simple Monadic Equational Reasoning 201 Proving the Unique Fixed-Point Principle Correct: An Adventure with Category Theory 202 Functional Pearl: Modular Rollback through Control Logging CREATE TABLE Authorship ( authID INTEGER, instID INTEGER, paperID INTEGER, authOrder INTEGER, PRIMARY KEY (authID, instID, paperID), FOREIGN KEY (authID) REFERENCES Authors (authID), FOREIGN KEY (instID) REFERENCES Inst (instID), FOREIGN KEY (paperID) REFERENCES Papers (paperID) ) 3 rows from Authorship table: authID instID paperID authOrder 50 1000 200 1 51 1000 200 2 51 1000 201 1
icfp_1
Find the country that the most papers are affiliated with.
SELECT t1.country FROM inst AS t1 JOIN authorship AS t2 ON t1.instid = t2.instid JOIN papers AS t3 ON t2.paperid = t3.paperid GROUP BY t1.country ORDER BY count(*) DESC LIMIT 1
CREATE TABLE Inst ( instID INTEGER, name TEXT, country TEXT, -- the home country of the institution (this is obviously an impoverished model) PRIMARY KEY (instID) ) 3 rows from Inst table: instID name country 1000 University of Oxford UK 1010 Northeastern University USA 1020 Indiana University USA CREATE TABLE Authors ( authID INTEGER, lname TEXT, fname TEXT, PRIMARY KEY (authID) ) 3 rows from Authors table: authID lname fname 50 Gibbons Jeremy 51 Hinze Ralf 52 James Daniel W. H. CREATE TABLE Papers ( paperID INTEGER, title TEXT, PRIMARY KEY (paperID) ) 3 rows from Papers table: paperID title 200 Just do it: Simple Monadic Equational Reasoning 201 Proving the Unique Fixed-Point Principle Correct: An Adventure with Category Theory 202 Functional Pearl: Modular Rollback through Control Logging CREATE TABLE Authorship ( authID INTEGER, instID INTEGER, paperID INTEGER, authOrder INTEGER, PRIMARY KEY (authID, instID, paperID), FOREIGN KEY (authID) REFERENCES Authors (authID), FOREIGN KEY (instID) REFERENCES Inst (instID), FOREIGN KEY (paperID) REFERENCES Papers (paperID) ) 3 rows from Authorship table: authID instID paperID authOrder 50 1000 200 1 51 1000 200 2 51 1000 201 1
icfp_1
Find the name of the organization that has published the largest number of papers.
SELECT t1.name FROM inst AS t1 JOIN authorship AS t2 ON t1.instid = t2.instid JOIN papers AS t3 ON t2.paperid = t3.paperid GROUP BY t1.name ORDER BY count(*) DESC LIMIT 1
CREATE TABLE Inst ( instID INTEGER, name TEXT, country TEXT, -- the home country of the institution (this is obviously an impoverished model) PRIMARY KEY (instID) ) 3 rows from Inst table: instID name country 1000 University of Oxford UK 1010 Northeastern University USA 1020 Indiana University USA CREATE TABLE Authors ( authID INTEGER, lname TEXT, fname TEXT, PRIMARY KEY (authID) ) 3 rows from Authors table: authID lname fname 50 Gibbons Jeremy 51 Hinze Ralf 52 James Daniel W. H. CREATE TABLE Papers ( paperID INTEGER, title TEXT, PRIMARY KEY (paperID) ) 3 rows from Papers table: paperID title 200 Just do it: Simple Monadic Equational Reasoning 201 Proving the Unique Fixed-Point Principle Correct: An Adventure with Category Theory 202 Functional Pearl: Modular Rollback through Control Logging CREATE TABLE Authorship ( authID INTEGER, instID INTEGER, paperID INTEGER, authOrder INTEGER, PRIMARY KEY (authID, instID, paperID), FOREIGN KEY (authID) REFERENCES Authors (authID), FOREIGN KEY (instID) REFERENCES Inst (instID), FOREIGN KEY (paperID) REFERENCES Papers (paperID) ) 3 rows from Authorship table: authID instID paperID authOrder 50 1000 200 1 51 1000 200 2 51 1000 201 1
icfp_1
Which institution has the most papers? Find the name of the institution.
SELECT t1.name FROM inst AS t1 JOIN authorship AS t2 ON t1.instid = t2.instid JOIN papers AS t3 ON t2.paperid = t3.paperid GROUP BY t1.name ORDER BY count(*) DESC LIMIT 1
CREATE TABLE Inst ( instID INTEGER, name TEXT, country TEXT, -- the home country of the institution (this is obviously an impoverished model) PRIMARY KEY (instID) ) 3 rows from Inst table: instID name country 1000 University of Oxford UK 1010 Northeastern University USA 1020 Indiana University USA CREATE TABLE Authors ( authID INTEGER, lname TEXT, fname TEXT, PRIMARY KEY (authID) ) 3 rows from Authors table: authID lname fname 50 Gibbons Jeremy 51 Hinze Ralf 52 James Daniel W. H. CREATE TABLE Papers ( paperID INTEGER, title TEXT, PRIMARY KEY (paperID) ) 3 rows from Papers table: paperID title 200 Just do it: Simple Monadic Equational Reasoning 201 Proving the Unique Fixed-Point Principle Correct: An Adventure with Category Theory 202 Functional Pearl: Modular Rollback through Control Logging CREATE TABLE Authorship ( authID INTEGER, instID INTEGER, paperID INTEGER, authOrder INTEGER, PRIMARY KEY (authID, instID, paperID), FOREIGN KEY (authID) REFERENCES Authors (authID), FOREIGN KEY (instID) REFERENCES Inst (instID), FOREIGN KEY (paperID) REFERENCES Papers (paperID) ) 3 rows from Authorship table: authID instID paperID authOrder 50 1000 200 1 51 1000 200 2 51 1000 201 1
icfp_1
Find the titles of the papers that contain the word "ML".
SELECT title FROM papers WHERE title LIKE "%ML%"
CREATE TABLE Inst ( instID INTEGER, name TEXT, country TEXT, -- the home country of the institution (this is obviously an impoverished model) PRIMARY KEY (instID) ) 3 rows from Inst table: instID name country 1000 University of Oxford UK 1010 Northeastern University USA 1020 Indiana University USA CREATE TABLE Authors ( authID INTEGER, lname TEXT, fname TEXT, PRIMARY KEY (authID) ) 3 rows from Authors table: authID lname fname 50 Gibbons Jeremy 51 Hinze Ralf 52 James Daniel W. H. CREATE TABLE Papers ( paperID INTEGER, title TEXT, PRIMARY KEY (paperID) ) 3 rows from Papers table: paperID title 200 Just do it: Simple Monadic Equational Reasoning 201 Proving the Unique Fixed-Point Principle Correct: An Adventure with Category Theory 202 Functional Pearl: Modular Rollback through Control Logging CREATE TABLE Authorship ( authID INTEGER, instID INTEGER, paperID INTEGER, authOrder INTEGER, PRIMARY KEY (authID, instID, paperID), FOREIGN KEY (authID) REFERENCES Authors (authID), FOREIGN KEY (instID) REFERENCES Inst (instID), FOREIGN KEY (paperID) REFERENCES Papers (paperID) ) 3 rows from Authorship table: authID instID paperID authOrder 50 1000 200 1 51 1000 200 2 51 1000 201 1
icfp_1
Which papers have the substring "ML" in their titles? Return the titles of the papers.
SELECT title FROM papers WHERE title LIKE "%ML%"
CREATE TABLE Inst ( instID INTEGER, name TEXT, country TEXT, -- the home country of the institution (this is obviously an impoverished model) PRIMARY KEY (instID) ) 3 rows from Inst table: instID name country 1000 University of Oxford UK 1010 Northeastern University USA 1020 Indiana University USA CREATE TABLE Authors ( authID INTEGER, lname TEXT, fname TEXT, PRIMARY KEY (authID) ) 3 rows from Authors table: authID lname fname 50 Gibbons Jeremy 51 Hinze Ralf 52 James Daniel W. H. CREATE TABLE Papers ( paperID INTEGER, title TEXT, PRIMARY KEY (paperID) ) 3 rows from Papers table: paperID title 200 Just do it: Simple Monadic Equational Reasoning 201 Proving the Unique Fixed-Point Principle Correct: An Adventure with Category Theory 202 Functional Pearl: Modular Rollback through Control Logging CREATE TABLE Authorship ( authID INTEGER, instID INTEGER, paperID INTEGER, authOrder INTEGER, PRIMARY KEY (authID, instID, paperID), FOREIGN KEY (authID) REFERENCES Authors (authID), FOREIGN KEY (instID) REFERENCES Inst (instID), FOREIGN KEY (paperID) REFERENCES Papers (paperID) ) 3 rows from Authorship table: authID instID paperID authOrder 50 1000 200 1 51 1000 200 2 51 1000 201 1
icfp_1
Which paper's title contains the word "Database"?
SELECT title FROM papers WHERE title LIKE "%Database%"
CREATE TABLE Inst ( instID INTEGER, name TEXT, country TEXT, -- the home country of the institution (this is obviously an impoverished model) PRIMARY KEY (instID) ) 3 rows from Inst table: instID name country 1000 University of Oxford UK 1010 Northeastern University USA 1020 Indiana University USA CREATE TABLE Authors ( authID INTEGER, lname TEXT, fname TEXT, PRIMARY KEY (authID) ) 3 rows from Authors table: authID lname fname 50 Gibbons Jeremy 51 Hinze Ralf 52 James Daniel W. H. CREATE TABLE Papers ( paperID INTEGER, title TEXT, PRIMARY KEY (paperID) ) 3 rows from Papers table: paperID title 200 Just do it: Simple Monadic Equational Reasoning 201 Proving the Unique Fixed-Point Principle Correct: An Adventure with Category Theory 202 Functional Pearl: Modular Rollback through Control Logging CREATE TABLE Authorship ( authID INTEGER, instID INTEGER, paperID INTEGER, authOrder INTEGER, PRIMARY KEY (authID, instID, paperID), FOREIGN KEY (authID) REFERENCES Authors (authID), FOREIGN KEY (instID) REFERENCES Inst (instID), FOREIGN KEY (paperID) REFERENCES Papers (paperID) ) 3 rows from Authorship table: authID instID paperID authOrder 50 1000 200 1 51 1000 200 2 51 1000 201 1
icfp_1
Which papers have the substring "Database" in their titles? Show the titles of the papers.
SELECT title FROM papers WHERE title LIKE "%Database%"
CREATE TABLE Inst ( instID INTEGER, name TEXT, country TEXT, -- the home country of the institution (this is obviously an impoverished model) PRIMARY KEY (instID) ) 3 rows from Inst table: instID name country 1000 University of Oxford UK 1010 Northeastern University USA 1020 Indiana University USA CREATE TABLE Authors ( authID INTEGER, lname TEXT, fname TEXT, PRIMARY KEY (authID) ) 3 rows from Authors table: authID lname fname 50 Gibbons Jeremy 51 Hinze Ralf 52 James Daniel W. H. CREATE TABLE Papers ( paperID INTEGER, title TEXT, PRIMARY KEY (paperID) ) 3 rows from Papers table: paperID title 200 Just do it: Simple Monadic Equational Reasoning 201 Proving the Unique Fixed-Point Principle Correct: An Adventure with Category Theory 202 Functional Pearl: Modular Rollback through Control Logging CREATE TABLE Authorship ( authID INTEGER, instID INTEGER, paperID INTEGER, authOrder INTEGER, PRIMARY KEY (authID, instID, paperID), FOREIGN KEY (authID) REFERENCES Authors (authID), FOREIGN KEY (instID) REFERENCES Inst (instID), FOREIGN KEY (paperID) REFERENCES Papers (paperID) ) 3 rows from Authorship table: authID instID paperID authOrder 50 1000 200 1 51 1000 200 2 51 1000 201 1
icfp_1
Find the first names of all the authors who have written a paper with title containing the word "Functional".
SELECT t1.fname FROM authors AS t1 JOIN authorship AS t2 ON t1.authid = t2.authid JOIN papers AS t3 ON t2.paperid = t3.paperid WHERE t3.title LIKE "%Functional%"
CREATE TABLE Inst ( instID INTEGER, name TEXT, country TEXT, -- the home country of the institution (this is obviously an impoverished model) PRIMARY KEY (instID) ) 3 rows from Inst table: instID name country 1000 University of Oxford UK 1010 Northeastern University USA 1020 Indiana University USA CREATE TABLE Authors ( authID INTEGER, lname TEXT, fname TEXT, PRIMARY KEY (authID) ) 3 rows from Authors table: authID lname fname 50 Gibbons Jeremy 51 Hinze Ralf 52 James Daniel W. H. CREATE TABLE Papers ( paperID INTEGER, title TEXT, PRIMARY KEY (paperID) ) 3 rows from Papers table: paperID title 200 Just do it: Simple Monadic Equational Reasoning 201 Proving the Unique Fixed-Point Principle Correct: An Adventure with Category Theory 202 Functional Pearl: Modular Rollback through Control Logging CREATE TABLE Authorship ( authID INTEGER, instID INTEGER, paperID INTEGER, authOrder INTEGER, PRIMARY KEY (authID, instID, paperID), FOREIGN KEY (authID) REFERENCES Authors (authID), FOREIGN KEY (instID) REFERENCES Inst (instID), FOREIGN KEY (paperID) REFERENCES Papers (paperID) ) 3 rows from Authorship table: authID instID paperID authOrder 50 1000 200 1 51 1000 200 2 51 1000 201 1
icfp_1
Who has written a paper that has the word "Functional" in its title? Return the first names of the authors.
SELECT t1.fname FROM authors AS t1 JOIN authorship AS t2 ON t1.authid = t2.authid JOIN papers AS t3 ON t2.paperid = t3.paperid WHERE t3.title LIKE "%Functional%"
CREATE TABLE Inst ( instID INTEGER, name TEXT, country TEXT, -- the home country of the institution (this is obviously an impoverished model) PRIMARY KEY (instID) ) 3 rows from Inst table: instID name country 1000 University of Oxford UK 1010 Northeastern University USA 1020 Indiana University USA CREATE TABLE Authors ( authID INTEGER, lname TEXT, fname TEXT, PRIMARY KEY (authID) ) 3 rows from Authors table: authID lname fname 50 Gibbons Jeremy 51 Hinze Ralf 52 James Daniel W. H. CREATE TABLE Papers ( paperID INTEGER, title TEXT, PRIMARY KEY (paperID) ) 3 rows from Papers table: paperID title 200 Just do it: Simple Monadic Equational Reasoning 201 Proving the Unique Fixed-Point Principle Correct: An Adventure with Category Theory 202 Functional Pearl: Modular Rollback through Control Logging CREATE TABLE Authorship ( authID INTEGER, instID INTEGER, paperID INTEGER, authOrder INTEGER, PRIMARY KEY (authID, instID, paperID), FOREIGN KEY (authID) REFERENCES Authors (authID), FOREIGN KEY (instID) REFERENCES Inst (instID), FOREIGN KEY (paperID) REFERENCES Papers (paperID) ) 3 rows from Authorship table: authID instID paperID authOrder 50 1000 200 1 51 1000 200 2 51 1000 201 1
icfp_1
Find the last names of all the authors that have written a paper with title containing the word "Monadic".
SELECT t1.lname FROM authors AS t1 JOIN authorship AS t2 ON t1.authid = t2.authid JOIN papers AS t3 ON t2.paperid = t3.paperid WHERE t3.title LIKE "%Monadic%"
CREATE TABLE Inst ( instID INTEGER, name TEXT, country TEXT, -- the home country of the institution (this is obviously an impoverished model) PRIMARY KEY (instID) ) 3 rows from Inst table: instID name country 1000 University of Oxford UK 1010 Northeastern University USA 1020 Indiana University USA CREATE TABLE Authors ( authID INTEGER, lname TEXT, fname TEXT, PRIMARY KEY (authID) ) 3 rows from Authors table: authID lname fname 50 Gibbons Jeremy 51 Hinze Ralf 52 James Daniel W. H. CREATE TABLE Papers ( paperID INTEGER, title TEXT, PRIMARY KEY (paperID) ) 3 rows from Papers table: paperID title 200 Just do it: Simple Monadic Equational Reasoning 201 Proving the Unique Fixed-Point Principle Correct: An Adventure with Category Theory 202 Functional Pearl: Modular Rollback through Control Logging CREATE TABLE Authorship ( authID INTEGER, instID INTEGER, paperID INTEGER, authOrder INTEGER, PRIMARY KEY (authID, instID, paperID), FOREIGN KEY (authID) REFERENCES Authors (authID), FOREIGN KEY (instID) REFERENCES Inst (instID), FOREIGN KEY (paperID) REFERENCES Papers (paperID) ) 3 rows from Authorship table: authID instID paperID authOrder 50 1000 200 1 51 1000 200 2 51 1000 201 1
icfp_1
Which authors have written a paper with title containing the word "Monadic"? Return their last names.
SELECT t1.lname FROM authors AS t1 JOIN authorship AS t2 ON t1.authid = t2.authid JOIN papers AS t3 ON t2.paperid = t3.paperid WHERE t3.title LIKE "%Monadic%"
CREATE TABLE Inst ( instID INTEGER, name TEXT, country TEXT, -- the home country of the institution (this is obviously an impoverished model) PRIMARY KEY (instID) ) 3 rows from Inst table: instID name country 1000 University of Oxford UK 1010 Northeastern University USA 1020 Indiana University USA CREATE TABLE Authors ( authID INTEGER, lname TEXT, fname TEXT, PRIMARY KEY (authID) ) 3 rows from Authors table: authID lname fname 50 Gibbons Jeremy 51 Hinze Ralf 52 James Daniel W. H. CREATE TABLE Papers ( paperID INTEGER, title TEXT, PRIMARY KEY (paperID) ) 3 rows from Papers table: paperID title 200 Just do it: Simple Monadic Equational Reasoning 201 Proving the Unique Fixed-Point Principle Correct: An Adventure with Category Theory 202 Functional Pearl: Modular Rollback through Control Logging CREATE TABLE Authorship ( authID INTEGER, instID INTEGER, paperID INTEGER, authOrder INTEGER, PRIMARY KEY (authID, instID, paperID), FOREIGN KEY (authID) REFERENCES Authors (authID), FOREIGN KEY (instID) REFERENCES Inst (instID), FOREIGN KEY (paperID) REFERENCES Papers (paperID) ) 3 rows from Authorship table: authID instID paperID authOrder 50 1000 200 1 51 1000 200 2 51 1000 201 1
icfp_1
Retrieve the title of the paper that has the largest number of authors.
SELECT t2.title FROM authorship AS t1 JOIN papers AS t2 ON t1.paperid = t2.paperid WHERE t1.authorder = (SELECT max(authorder) FROM authorship)
CREATE TABLE Inst ( instID INTEGER, name TEXT, country TEXT, -- the home country of the institution (this is obviously an impoverished model) PRIMARY KEY (instID) ) 3 rows from Inst table: instID name country 1000 University of Oxford UK 1010 Northeastern University USA 1020 Indiana University USA CREATE TABLE Authors ( authID INTEGER, lname TEXT, fname TEXT, PRIMARY KEY (authID) ) 3 rows from Authors table: authID lname fname 50 Gibbons Jeremy 51 Hinze Ralf 52 James Daniel W. H. CREATE TABLE Papers ( paperID INTEGER, title TEXT, PRIMARY KEY (paperID) ) 3 rows from Papers table: paperID title 200 Just do it: Simple Monadic Equational Reasoning 201 Proving the Unique Fixed-Point Principle Correct: An Adventure with Category Theory 202 Functional Pearl: Modular Rollback through Control Logging CREATE TABLE Authorship ( authID INTEGER, instID INTEGER, paperID INTEGER, authOrder INTEGER, PRIMARY KEY (authID, instID, paperID), FOREIGN KEY (authID) REFERENCES Authors (authID), FOREIGN KEY (instID) REFERENCES Inst (instID), FOREIGN KEY (paperID) REFERENCES Papers (paperID) ) 3 rows from Authorship table: authID instID paperID authOrder 50 1000 200 1 51 1000 200 2 51 1000 201 1
icfp_1
Which paper has the most authors? Give me the paper title.
SELECT t2.title FROM authorship AS t1 JOIN papers AS t2 ON t1.paperid = t2.paperid WHERE t1.authorder = (SELECT max(authorder) FROM authorship)
CREATE TABLE Inst ( instID INTEGER, name TEXT, country TEXT, -- the home country of the institution (this is obviously an impoverished model) PRIMARY KEY (instID) ) 3 rows from Inst table: instID name country 1000 University of Oxford UK 1010 Northeastern University USA 1020 Indiana University USA CREATE TABLE Authors ( authID INTEGER, lname TEXT, fname TEXT, PRIMARY KEY (authID) ) 3 rows from Authors table: authID lname fname 50 Gibbons Jeremy 51 Hinze Ralf 52 James Daniel W. H. CREATE TABLE Papers ( paperID INTEGER, title TEXT, PRIMARY KEY (paperID) ) 3 rows from Papers table: paperID title 200 Just do it: Simple Monadic Equational Reasoning 201 Proving the Unique Fixed-Point Principle Correct: An Adventure with Category Theory 202 Functional Pearl: Modular Rollback through Control Logging CREATE TABLE Authorship ( authID INTEGER, instID INTEGER, paperID INTEGER, authOrder INTEGER, PRIMARY KEY (authID, instID, paperID), FOREIGN KEY (authID) REFERENCES Authors (authID), FOREIGN KEY (instID) REFERENCES Inst (instID), FOREIGN KEY (paperID) REFERENCES Papers (paperID) ) 3 rows from Authorship table: authID instID paperID authOrder 50 1000 200 1 51 1000 200 2 51 1000 201 1
icfp_1
What is the first name of the author with last name "Ueno"?
SELECT fname FROM authors WHERE lname = "Ueno"
CREATE TABLE Inst ( instID INTEGER, name TEXT, country TEXT, -- the home country of the institution (this is obviously an impoverished model) PRIMARY KEY (instID) ) 3 rows from Inst table: instID name country 1000 University of Oxford UK 1010 Northeastern University USA 1020 Indiana University USA CREATE TABLE Authors ( authID INTEGER, lname TEXT, fname TEXT, PRIMARY KEY (authID) ) 3 rows from Authors table: authID lname fname 50 Gibbons Jeremy 51 Hinze Ralf 52 James Daniel W. H. CREATE TABLE Papers ( paperID INTEGER, title TEXT, PRIMARY KEY (paperID) ) 3 rows from Papers table: paperID title 200 Just do it: Simple Monadic Equational Reasoning 201 Proving the Unique Fixed-Point Principle Correct: An Adventure with Category Theory 202 Functional Pearl: Modular Rollback through Control Logging CREATE TABLE Authorship ( authID INTEGER, instID INTEGER, paperID INTEGER, authOrder INTEGER, PRIMARY KEY (authID, instID, paperID), FOREIGN KEY (authID) REFERENCES Authors (authID), FOREIGN KEY (instID) REFERENCES Inst (instID), FOREIGN KEY (paperID) REFERENCES Papers (paperID) ) 3 rows from Authorship table: authID instID paperID authOrder 50 1000 200 1 51 1000 200 2 51 1000 201 1
icfp_1
Which authors have last name "Ueno"? List their first names.
SELECT fname FROM authors WHERE lname = "Ueno"
CREATE TABLE Inst ( instID INTEGER, name TEXT, country TEXT, -- the home country of the institution (this is obviously an impoverished model) PRIMARY KEY (instID) ) 3 rows from Inst table: instID name country 1000 University of Oxford UK 1010 Northeastern University USA 1020 Indiana University USA CREATE TABLE Authors ( authID INTEGER, lname TEXT, fname TEXT, PRIMARY KEY (authID) ) 3 rows from Authors table: authID lname fname 50 Gibbons Jeremy 51 Hinze Ralf 52 James Daniel W. H. CREATE TABLE Papers ( paperID INTEGER, title TEXT, PRIMARY KEY (paperID) ) 3 rows from Papers table: paperID title 200 Just do it: Simple Monadic Equational Reasoning 201 Proving the Unique Fixed-Point Principle Correct: An Adventure with Category Theory 202 Functional Pearl: Modular Rollback through Control Logging CREATE TABLE Authorship ( authID INTEGER, instID INTEGER, paperID INTEGER, authOrder INTEGER, PRIMARY KEY (authID, instID, paperID), FOREIGN KEY (authID) REFERENCES Authors (authID), FOREIGN KEY (instID) REFERENCES Inst (instID), FOREIGN KEY (paperID) REFERENCES Papers (paperID) ) 3 rows from Authorship table: authID instID paperID authOrder 50 1000 200 1 51 1000 200 2 51 1000 201 1
icfp_1
Find the last name of the author with first name "Amal".
SELECT lname FROM authors WHERE fname = "Amal"
CREATE TABLE Inst ( instID INTEGER, name TEXT, country TEXT, -- the home country of the institution (this is obviously an impoverished model) PRIMARY KEY (instID) ) 3 rows from Inst table: instID name country 1000 University of Oxford UK 1010 Northeastern University USA 1020 Indiana University USA CREATE TABLE Authors ( authID INTEGER, lname TEXT, fname TEXT, PRIMARY KEY (authID) ) 3 rows from Authors table: authID lname fname 50 Gibbons Jeremy 51 Hinze Ralf 52 James Daniel W. H. CREATE TABLE Papers ( paperID INTEGER, title TEXT, PRIMARY KEY (paperID) ) 3 rows from Papers table: paperID title 200 Just do it: Simple Monadic Equational Reasoning 201 Proving the Unique Fixed-Point Principle Correct: An Adventure with Category Theory 202 Functional Pearl: Modular Rollback through Control Logging CREATE TABLE Authorship ( authID INTEGER, instID INTEGER, paperID INTEGER, authOrder INTEGER, PRIMARY KEY (authID, instID, paperID), FOREIGN KEY (authID) REFERENCES Authors (authID), FOREIGN KEY (instID) REFERENCES Inst (instID), FOREIGN KEY (paperID) REFERENCES Papers (paperID) ) 3 rows from Authorship table: authID instID paperID authOrder 50 1000 200 1 51 1000 200 2 51 1000 201 1
icfp_1
Which authors have first name "Amal"? List their last names.
SELECT lname FROM authors WHERE fname = "Amal"
CREATE TABLE Inst ( instID INTEGER, name TEXT, country TEXT, -- the home country of the institution (this is obviously an impoverished model) PRIMARY KEY (instID) ) 3 rows from Inst table: instID name country 1000 University of Oxford UK 1010 Northeastern University USA 1020 Indiana University USA CREATE TABLE Authors ( authID INTEGER, lname TEXT, fname TEXT, PRIMARY KEY (authID) ) 3 rows from Authors table: authID lname fname 50 Gibbons Jeremy 51 Hinze Ralf 52 James Daniel W. H. CREATE TABLE Papers ( paperID INTEGER, title TEXT, PRIMARY KEY (paperID) ) 3 rows from Papers table: paperID title 200 Just do it: Simple Monadic Equational Reasoning 201 Proving the Unique Fixed-Point Principle Correct: An Adventure with Category Theory 202 Functional Pearl: Modular Rollback through Control Logging CREATE TABLE Authorship ( authID INTEGER, instID INTEGER, paperID INTEGER, authOrder INTEGER, PRIMARY KEY (authID, instID, paperID), FOREIGN KEY (authID) REFERENCES Authors (authID), FOREIGN KEY (instID) REFERENCES Inst (instID), FOREIGN KEY (paperID) REFERENCES Papers (paperID) ) 3 rows from Authorship table: authID instID paperID authOrder 50 1000 200 1 51 1000 200 2 51 1000 201 1
icfp_1
Find the first names of all the authors ordered in alphabetical order.
SELECT fname FROM authors ORDER BY fname
CREATE TABLE Inst ( instID INTEGER, name TEXT, country TEXT, -- the home country of the institution (this is obviously an impoverished model) PRIMARY KEY (instID) ) 3 rows from Inst table: instID name country 1000 University of Oxford UK 1010 Northeastern University USA 1020 Indiana University USA CREATE TABLE Authors ( authID INTEGER, lname TEXT, fname TEXT, PRIMARY KEY (authID) ) 3 rows from Authors table: authID lname fname 50 Gibbons Jeremy 51 Hinze Ralf 52 James Daniel W. H. CREATE TABLE Papers ( paperID INTEGER, title TEXT, PRIMARY KEY (paperID) ) 3 rows from Papers table: paperID title 200 Just do it: Simple Monadic Equational Reasoning 201 Proving the Unique Fixed-Point Principle Correct: An Adventure with Category Theory 202 Functional Pearl: Modular Rollback through Control Logging CREATE TABLE Authorship ( authID INTEGER, instID INTEGER, paperID INTEGER, authOrder INTEGER, PRIMARY KEY (authID, instID, paperID), FOREIGN KEY (authID) REFERENCES Authors (authID), FOREIGN KEY (instID) REFERENCES Inst (instID), FOREIGN KEY (paperID) REFERENCES Papers (paperID) ) 3 rows from Authorship table: authID instID paperID authOrder 50 1000 200 1 51 1000 200 2 51 1000 201 1
icfp_1
Sort the first names of all the authors in alphabetical order.
SELECT fname FROM authors ORDER BY fname
CREATE TABLE Inst ( instID INTEGER, name TEXT, country TEXT, -- the home country of the institution (this is obviously an impoverished model) PRIMARY KEY (instID) ) 3 rows from Inst table: instID name country 1000 University of Oxford UK 1010 Northeastern University USA 1020 Indiana University USA CREATE TABLE Authors ( authID INTEGER, lname TEXT, fname TEXT, PRIMARY KEY (authID) ) 3 rows from Authors table: authID lname fname 50 Gibbons Jeremy 51 Hinze Ralf 52 James Daniel W. H. CREATE TABLE Papers ( paperID INTEGER, title TEXT, PRIMARY KEY (paperID) ) 3 rows from Papers table: paperID title 200 Just do it: Simple Monadic Equational Reasoning 201 Proving the Unique Fixed-Point Principle Correct: An Adventure with Category Theory 202 Functional Pearl: Modular Rollback through Control Logging CREATE TABLE Authorship ( authID INTEGER, instID INTEGER, paperID INTEGER, authOrder INTEGER, PRIMARY KEY (authID, instID, paperID), FOREIGN KEY (authID) REFERENCES Authors (authID), FOREIGN KEY (instID) REFERENCES Inst (instID), FOREIGN KEY (paperID) REFERENCES Papers (paperID) ) 3 rows from Authorship table: authID instID paperID authOrder 50 1000 200 1 51 1000 200 2 51 1000 201 1
icfp_1
Retrieve all the last names of authors in alphabetical order.
SELECT lname FROM authors ORDER BY lname
CREATE TABLE Inst ( instID INTEGER, name TEXT, country TEXT, -- the home country of the institution (this is obviously an impoverished model) PRIMARY KEY (instID) ) 3 rows from Inst table: instID name country 1000 University of Oxford UK 1010 Northeastern University USA 1020 Indiana University USA CREATE TABLE Authors ( authID INTEGER, lname TEXT, fname TEXT, PRIMARY KEY (authID) ) 3 rows from Authors table: authID lname fname 50 Gibbons Jeremy 51 Hinze Ralf 52 James Daniel W. H. CREATE TABLE Papers ( paperID INTEGER, title TEXT, PRIMARY KEY (paperID) ) 3 rows from Papers table: paperID title 200 Just do it: Simple Monadic Equational Reasoning 201 Proving the Unique Fixed-Point Principle Correct: An Adventure with Category Theory 202 Functional Pearl: Modular Rollback through Control Logging CREATE TABLE Authorship ( authID INTEGER, instID INTEGER, paperID INTEGER, authOrder INTEGER, PRIMARY KEY (authID, instID, paperID), FOREIGN KEY (authID) REFERENCES Authors (authID), FOREIGN KEY (instID) REFERENCES Inst (instID), FOREIGN KEY (paperID) REFERENCES Papers (paperID) ) 3 rows from Authorship table: authID instID paperID authOrder 50 1000 200 1 51 1000 200 2 51 1000 201 1
icfp_1
Give me a list of all the last names of authors sorted in alphabetical order
SELECT lname FROM authors ORDER BY lname
CREATE TABLE Inst ( instID INTEGER, name TEXT, country TEXT, -- the home country of the institution (this is obviously an impoverished model) PRIMARY KEY (instID) ) 3 rows from Inst table: instID name country 1000 University of Oxford UK 1010 Northeastern University USA 1020 Indiana University USA CREATE TABLE Authors ( authID INTEGER, lname TEXT, fname TEXT, PRIMARY KEY (authID) ) 3 rows from Authors table: authID lname fname 50 Gibbons Jeremy 51 Hinze Ralf 52 James Daniel W. H. CREATE TABLE Papers ( paperID INTEGER, title TEXT, PRIMARY KEY (paperID) ) 3 rows from Papers table: paperID title 200 Just do it: Simple Monadic Equational Reasoning 201 Proving the Unique Fixed-Point Principle Correct: An Adventure with Category Theory 202 Functional Pearl: Modular Rollback through Control Logging CREATE TABLE Authorship ( authID INTEGER, instID INTEGER, paperID INTEGER, authOrder INTEGER, PRIMARY KEY (authID, instID, paperID), FOREIGN KEY (authID) REFERENCES Authors (authID), FOREIGN KEY (instID) REFERENCES Inst (instID), FOREIGN KEY (paperID) REFERENCES Papers (paperID) ) 3 rows from Authorship table: authID instID paperID authOrder 50 1000 200 1 51 1000 200 2 51 1000 201 1
icfp_1
Retrieve all the first and last names of authors in the alphabetical order of last names.
SELECT fname , lname FROM authors ORDER BY lname
CREATE TABLE Inst ( instID INTEGER, name TEXT, country TEXT, -- the home country of the institution (this is obviously an impoverished model) PRIMARY KEY (instID) ) 3 rows from Inst table: instID name country 1000 University of Oxford UK 1010 Northeastern University USA 1020 Indiana University USA CREATE TABLE Authors ( authID INTEGER, lname TEXT, fname TEXT, PRIMARY KEY (authID) ) 3 rows from Authors table: authID lname fname 50 Gibbons Jeremy 51 Hinze Ralf 52 James Daniel W. H. CREATE TABLE Papers ( paperID INTEGER, title TEXT, PRIMARY KEY (paperID) ) 3 rows from Papers table: paperID title 200 Just do it: Simple Monadic Equational Reasoning 201 Proving the Unique Fixed-Point Principle Correct: An Adventure with Category Theory 202 Functional Pearl: Modular Rollback through Control Logging CREATE TABLE Authorship ( authID INTEGER, instID INTEGER, paperID INTEGER, authOrder INTEGER, PRIMARY KEY (authID, instID, paperID), FOREIGN KEY (authID) REFERENCES Authors (authID), FOREIGN KEY (instID) REFERENCES Inst (instID), FOREIGN KEY (paperID) REFERENCES Papers (paperID) ) 3 rows from Authorship table: authID instID paperID authOrder 50 1000 200 1 51 1000 200 2 51 1000 201 1
icfp_1
Sort the list of all the first and last names of authors in alphabetical order of the last names.
SELECT fname , lname FROM authors ORDER BY lname
CREATE TABLE Inst ( instID INTEGER, name TEXT, country TEXT, -- the home country of the institution (this is obviously an impoverished model) PRIMARY KEY (instID) ) 3 rows from Inst table: instID name country 1000 University of Oxford UK 1010 Northeastern University USA 1020 Indiana University USA CREATE TABLE Authors ( authID INTEGER, lname TEXT, fname TEXT, PRIMARY KEY (authID) ) 3 rows from Authors table: authID lname fname 50 Gibbons Jeremy 51 Hinze Ralf 52 James Daniel W. H. CREATE TABLE Papers ( paperID INTEGER, title TEXT, PRIMARY KEY (paperID) ) 3 rows from Papers table: paperID title 200 Just do it: Simple Monadic Equational Reasoning 201 Proving the Unique Fixed-Point Principle Correct: An Adventure with Category Theory 202 Functional Pearl: Modular Rollback through Control Logging CREATE TABLE Authorship ( authID INTEGER, instID INTEGER, paperID INTEGER, authOrder INTEGER, PRIMARY KEY (authID, instID, paperID), FOREIGN KEY (authID) REFERENCES Authors (authID), FOREIGN KEY (instID) REFERENCES Inst (instID), FOREIGN KEY (paperID) REFERENCES Papers (paperID) ) 3 rows from Authorship table: authID instID paperID authOrder 50 1000 200 1 51 1000 200 2 51 1000 201 1
sakila_1
How many different last names do the actors and actresses have?
SELECT count(DISTINCT last_name) FROM actor
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
Count the number of different last names actors have.
SELECT count(DISTINCT last_name) FROM actor
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
What is the most popular first name of the actors?
SELECT first_name FROM actor GROUP BY first_name ORDER BY count(*) DESC LIMIT 1
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
Return the most common first name among all actors.
SELECT first_name FROM actor GROUP BY first_name ORDER BY count(*) DESC LIMIT 1
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
What is the most popular full name of the actors?
SELECT first_name , last_name FROM actor GROUP BY first_name , last_name ORDER BY count(*) DESC LIMIT 1
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
Return the most common full name among all actors.
SELECT first_name , last_name FROM actor GROUP BY first_name , last_name ORDER BY count(*) DESC LIMIT 1
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
Which districts have at least two addresses?
SELECT district FROM address GROUP BY district HAVING count(*) >= 2
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
Give the districts which have two or more addresses.
SELECT district FROM address GROUP BY district HAVING count(*) >= 2
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
What is the phone number and postal code of the address 1031 Daugavpils Parkway?
SELECT phone , postal_code FROM address WHERE address = '1031 Daugavpils Parkway'
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
Give the phone and postal code corresponding to the address '1031 Daugavpils Parkway'.
SELECT phone , postal_code FROM address WHERE address = '1031 Daugavpils Parkway'
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
Which city has the most addresses? List the city name, number of addresses, and city id.
SELECT T2.city , count(*) , T1.city_id FROM address AS T1 JOIN city AS T2 ON T1.city_id = T2.city_id GROUP BY T1.city_id ORDER BY count(*) DESC LIMIT 1
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
What are the city name, id, and number of addresses corresponding to the city with the most addressed?
SELECT T2.city , count(*) , T1.city_id FROM address AS T1 JOIN city AS T2 ON T1.city_id = T2.city_id GROUP BY T1.city_id ORDER BY count(*) DESC LIMIT 1
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
How many addresses are in the district of California?
SELECT count(*) FROM address WHERE district = 'California'
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
Count the number of addressed in the California district.
SELECT count(*) FROM address WHERE district = 'California'
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
Which film is rented at a fee of 0.99 and has less than 3 in the inventory? List the film title and id.
SELECT title , film_id FROM film WHERE rental_rate = 0.99 INTERSECT SELECT T1.title , T1.film_id FROM film AS T1 JOIN inventory AS T2 ON T1.film_id = T2.film_id GROUP BY T1.film_id HAVING count(*) < 3
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
What are the title and id of the film which has a rental rate of 0.99 and an inventory of below 3?
SELECT title , film_id FROM film WHERE rental_rate = 0.99 INTERSECT SELECT T1.title , T1.film_id FROM film AS T1 JOIN inventory AS T2 ON T1.film_id = T2.film_id GROUP BY T1.film_id HAVING count(*) < 3
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
How many cities are in Australia?
SELECT count(*) FROM city AS T1 JOIN country AS T2 ON T1.country_id = T2.country_id WHERE T2.country = 'Australia'
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
Count the number of cities in Australia.
SELECT count(*) FROM city AS T1 JOIN country AS T2 ON T1.country_id = T2.country_id WHERE T2.country = 'Australia'
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
Which countries have at least 3 cities?
SELECT T2.country FROM city AS T1 JOIN country AS T2 ON T1.country_id = T2.country_id GROUP BY T2.country_id HAVING count(*) >= 3
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
What are the countries that contain 3 or more cities?
SELECT T2.country FROM city AS T1 JOIN country AS T2 ON T1.country_id = T2.country_id GROUP BY T2.country_id HAVING count(*) >= 3
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
Find all the payment dates for the payments with an amount larger than 10 and the payments handled by a staff person with the first name Elsa.
SELECT payment_date FROM payment WHERE amount > 10 UNION SELECT T1.payment_date FROM payment AS T1 JOIN staff AS T2 ON T1.staff_id = T2.staff_id WHERE T2.first_name = 'Elsa'
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
What are the payment dates for any payments that have an amount greater than 10 or were handled by a staff member with the first name Elsa?
SELECT payment_date FROM payment WHERE amount > 10 UNION SELECT T1.payment_date FROM payment AS T1 JOIN staff AS T2 ON T1.staff_id = T2.staff_id WHERE T2.first_name = 'Elsa'
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
How many customers have an active value of 1?
SELECT count(*) FROM customer WHERE active = '1'
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
Count the number of customers who are active.
SELECT count(*) FROM customer WHERE active = '1'
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
Which film has the highest rental rate? And what is the rate?
SELECT title , rental_rate FROM film ORDER BY rental_rate DESC LIMIT 1
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
What are the title and rental rate of the film with the highest rental rate?
SELECT title , rental_rate FROM film ORDER BY rental_rate DESC LIMIT 1
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
Which film has the most number of actors or actresses? List the film name, film id and description.
SELECT T2.title , T2.film_id , T2.description FROM film_actor AS T1 JOIN film AS T2 ON T1.film_id = T2.film_id GROUP BY T2.film_id ORDER BY count(*) DESC LIMIT 1
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
What are the title, id, and description of the movie with the greatest number of actors?
SELECT T2.title , T2.film_id , T2.description FROM film_actor AS T1 JOIN film AS T2 ON T1.film_id = T2.film_id GROUP BY T2.film_id ORDER BY count(*) DESC LIMIT 1
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
Which film actor (actress) starred the most films? List his or her first name, last name and actor id.
SELECT T2.first_name , T2.last_name , T2.actor_id FROM film_actor AS T1 JOIN actor AS T2 ON T1.actor_id = T2.actor_id GROUP BY T2.actor_id ORDER BY count(*) DESC LIMIT 1
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
Return the full name and id of the actor or actress who starred in the greatest number of films.
SELECT T2.first_name , T2.last_name , T2.actor_id FROM film_actor AS T1 JOIN actor AS T2 ON T1.actor_id = T2.actor_id GROUP BY T2.actor_id ORDER BY count(*) DESC LIMIT 1
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
Which film actors (actresses) played a role in more than 30 films? List his or her first name and last name.
SELECT T2.first_name , T2.last_name FROM film_actor AS T1 JOIN actor AS T2 ON T1.actor_id = T2.actor_id GROUP BY T2.actor_id HAVING count(*) > 30
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
What are the full names of actors who had roles in more than 30 films?
SELECT T2.first_name , T2.last_name FROM film_actor AS T1 JOIN actor AS T2 ON T1.actor_id = T2.actor_id GROUP BY T2.actor_id HAVING count(*) > 30
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
Which store owns most items?
SELECT store_id FROM inventory GROUP BY store_id ORDER BY count(*) DESC LIMIT 1
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
What is the id of the store that has the most items in inventory?
SELECT store_id FROM inventory GROUP BY store_id ORDER BY count(*) DESC LIMIT 1
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
What is the total amount of all payments?
SELECT sum(amount) FROM payment
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
Return the sum of all payment amounts.
SELECT sum(amount) FROM payment
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
Which customer, who has made at least one payment, has spent the least money? List his or her first name, last name, and the id.
SELECT T1.first_name , T1.last_name , T1.customer_id FROM customer AS T1 JOIN payment AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id ORDER BY sum(amount) ASC LIMIT 1
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
What is the full name and id of the customer who has the lowest total amount of payment?
SELECT T1.first_name , T1.last_name , T1.customer_id FROM customer AS T1 JOIN payment AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id ORDER BY sum(amount) ASC LIMIT 1
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
What is the genre name of the film HUNGER ROOF?
SELECT T1.name FROM category AS T1 JOIN film_category AS T2 ON T1.category_id = T2.category_id JOIN film AS T3 ON T2.film_id = T3.film_id WHERE T3.title = 'HUNGER ROOF'
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
Return the name of the category to which the film 'HUNGER ROOF' belongs.
SELECT T1.name FROM category AS T1 JOIN film_category AS T2 ON T1.category_id = T2.category_id JOIN film AS T3 ON T2.film_id = T3.film_id WHERE T3.title = 'HUNGER ROOF'
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
How many films are there in each category? List the genre name, genre id and the count.
SELECT T2.name , T1.category_id , count(*) FROM film_category AS T1 JOIN category AS T2 ON T1.category_id = T2.category_id GROUP BY T1.category_id
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
What are the names and ids of the different categories, and how many films are in each?
SELECT T2.name , T1.category_id , count(*) FROM film_category AS T1 JOIN category AS T2 ON T1.category_id = T2.category_id GROUP BY T1.category_id
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
Which film has the most copies in the inventory? List both title and id.
SELECT T1.title , T1.film_id FROM film AS T1 JOIN inventory AS T2 ON T1.film_id = T2.film_id GROUP BY T1.film_id ORDER BY count(*) DESC LIMIT 1
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
What is the title and id of the film that has the greatest number of copies in inventory?
SELECT T1.title , T1.film_id FROM film AS T1 JOIN inventory AS T2 ON T1.film_id = T2.film_id GROUP BY T1.film_id ORDER BY count(*) DESC LIMIT 1
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
What is the film title and inventory id of the item in the inventory which was rented most frequently?
SELECT T1.title , T2.inventory_id FROM film AS T1 JOIN inventory AS T2 ON T1.film_id = T2.film_id JOIN rental AS T3 ON T2.inventory_id = T3.inventory_id GROUP BY T2.inventory_id ORDER BY count(*) DESC LIMIT 1
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
Return the title and inventory id of the film that is rented most often.
SELECT T1.title , T2.inventory_id FROM film AS T1 JOIN inventory AS T2 ON T1.film_id = T2.film_id JOIN rental AS T3 ON T2.inventory_id = T3.inventory_id GROUP BY T2.inventory_id ORDER BY count(*) DESC LIMIT 1
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
How many languages are in these films?
SELECT count(DISTINCT language_id) FROM film
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
Count the number of different languages in these films.
SELECT count(DISTINCT language_id) FROM film
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
What are all the movies rated as R? List the titles.
SELECT title FROM film WHERE rating = 'R'
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
Return the titles of any movies with an R rating.
SELECT title FROM film WHERE rating = 'R'
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
Where is store 1 located?
SELECT T2.address FROM store AS T1 JOIN address AS T2 ON T1.address_id = T2.address_id WHERE store_id = 1
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
Return the address of store 1.
SELECT T2.address FROM store AS T1 JOIN address AS T2 ON T1.address_id = T2.address_id WHERE store_id = 1
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
Which staff handled least number of payments? List the full name and the id.
SELECT T1.first_name , T1.last_name , T1.staff_id FROM staff AS T1 JOIN payment AS T2 ON T1.staff_id = T2.staff_id GROUP BY T1.staff_id ORDER BY count(*) ASC LIMIT 1
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
Give the full name and staff id of the staff who has handled the fewest payments.
SELECT T1.first_name , T1.last_name , T1.staff_id FROM staff AS T1 JOIN payment AS T2 ON T1.staff_id = T2.staff_id GROUP BY T1.staff_id ORDER BY count(*) ASC LIMIT 1
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
Which language does the film AIRPORT POLLOCK use? List the language name.
SELECT T2.name FROM film AS T1 JOIN LANGUAGE AS T2 ON T1.language_id = T2.language_id WHERE T1.title = 'AIRPORT POLLOCK'
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
What is the name of the language that the film 'AIRPORT POLLOCK' is in?
SELECT T2.name FROM film AS T1 JOIN LANGUAGE AS T2 ON T1.language_id = T2.language_id WHERE T1.title = 'AIRPORT POLLOCK'
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
How many stores are there?
SELECT count(*) FROM store
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
Count the number of stores.
SELECT count(*) FROM store
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
How many kinds of different ratings are listed?
SELECT count(DISTINCT rating) FROM film
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
Count the number of different film ratings.
SELECT count(DISTINCT rating) FROM film
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
Which movies have 'Deleted Scenes' as a substring in the special feature?
SELECT title FROM film WHERE special_features LIKE '%Deleted Scenes%'
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
Return the titles of films that include 'Deleted Scenes' in their special feature section.
SELECT title FROM film WHERE special_features LIKE '%Deleted Scenes%'
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
How many items in inventory does store 1 have?
SELECT count(*) FROM inventory WHERE store_id = 1
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
Count the number of items store 1 has in stock.
SELECT count(*) FROM inventory WHERE store_id = 1
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
When did the first payment happen?
SELECT payment_date FROM payment ORDER BY payment_date ASC LIMIT 1
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
What was the date of the earliest payment?
SELECT payment_date FROM payment ORDER BY payment_date ASC LIMIT 1
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
Where does the customer with the first name Linda live? And what is her email?
SELECT T2.address , T1.email FROM customer AS T1 JOIN address AS T2 ON T2.address_id = T1.address_id WHERE T1.first_name = 'LINDA'
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
Return the address and email of the customer with the first name Linda.
SELECT T2.address , T1.email FROM customer AS T1 JOIN address AS T2 ON T2.address_id = T1.address_id WHERE T1.first_name = 'LINDA'
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
Find all the films longer than 100 minutes, or rated PG, except those who cost more than 200 for replacement. List the titles.
SELECT title FROM film WHERE LENGTH > 100 OR rating = 'PG' EXCEPT SELECT title FROM film WHERE replacement_cost > 200
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
What are the titles of films that are either longer than 100 minutes or rated PG other than those that cost more than 200 to replace?
SELECT title FROM film WHERE LENGTH > 100 OR rating = 'PG' EXCEPT SELECT title FROM film WHERE replacement_cost > 200
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
What is the first name and the last name of the customer who made the earliest rental?
SELECT T1.first_name , T1.last_name FROM customer AS T1 JOIN rental AS T2 ON T1.customer_id = T2.customer_id ORDER BY T2.rental_date ASC LIMIT 1
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
Return the full name of the customer who made the first rental.
SELECT T1.first_name , T1.last_name FROM customer AS T1 JOIN rental AS T2 ON T1.customer_id = T2.customer_id ORDER BY T2.rental_date ASC LIMIT 1
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
What is the full name of the staff member who has rented a film to a customer with the first name April and the last name Burns?
SELECT DISTINCT T1.first_name , T1.last_name FROM staff AS T1 JOIN rental AS T2 ON T1.staff_id = T2.staff_id JOIN customer AS T3 ON T2.customer_id = T3.customer_id WHERE T3.first_name = 'APRIL' AND T3.last_name = 'BURNS'
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
Return the full name of the staff who provided a customer with the first name April and the last name Burns with a film rental.
SELECT DISTINCT T1.first_name , T1.last_name FROM staff AS T1 JOIN rental AS T2 ON T1.staff_id = T2.staff_id JOIN customer AS T3 ON T2.customer_id = T3.customer_id WHERE T3.first_name = 'APRIL' AND T3.last_name = 'BURNS'
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
Which store has most the customers?
SELECT store_id FROM customer GROUP BY store_id ORDER BY count(*) DESC LIMIT 1
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []
sakila_1
Return the id of the store with the most customers.
SELECT store_id FROM customer GROUP BY store_id ORDER BY count(*) DESC LIMIT 1
CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ) 3 rows from actor table: actor_id first_name last_name last_update 1 PENELOPE GUINESS 2006-02-15 04:34:33 2 NICK WAHLBERG 2006-02-15 04:34:33 3 ED CHASE 2006-02-15 04:34:33 CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (address_id), FOREIGN KEY (city_id) REFERENCES city (city_id) ) 3 rows from address table: address_id address address2 district city_id postal_code phone last_update 1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30 2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30 3 23 Workhaven Lane None Alberta 300 14033335568 2006-02-15 04:45:30 CREATE TABLE category ( category_id TINYINT UNSIGNED NOT NULL, name VARCHAR(25) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (category_id) ) 3 rows from category table: category_id name last_update 1 Action 2006-02-15 04:46:27 2 Animation 2006-02-15 04:46:27 3 Children 2006-02-15 04:46:27 CREATE TABLE city ( city_id SMALLINT UNSIGNED NOT NULL, city VARCHAR(50) NOT NULL, country_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (city_id), FOREIGN KEY (country_id) REFERENCES country (country_id) ) 3 rows from city table: city_id city country_id last_update 1 A Corua (La Corua) 87 2006-02-15 04:45:25 2 Abha 82 2006-02-15 04:45:25 3 Abu Dhabi 101 2006-02-15 04:45:25 CREATE TABLE country ( country_id SMALLINT UNSIGNED NOT NULL, country VARCHAR(50) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (country_id) ) 3 rows from country table: country_id country last_update 1 Afghanistan 2006-02-15 04:44:00 2 Algeria 2006-02-15 04:44:00 3 American Samoa 2006-02-15 04:44:00 CREATE TABLE customer ( customer_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, email VARCHAR(50) DEFAULT NULL, address_id SMALLINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, create_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (customer_id), FOREIGN KEY (address_id) REFERENCES address (address_id), FOREIGN KEY (store_id) REFERENCES store (store_id) ) 3 rows from customer table: customer_id store_id first_name last_name email address_id active create_date last_update 1 1 MARY SMITH MARY.SMITH@sakilacustomer.org 5 1 2006-02-14 22:04:36 2006-02-15 04:57:20 2 1 PATRICIA JOHNSON PATRICIA.JOHNSON@sakilacustomer.org 6 1 2006-02-14 22:04:36 2006-02-15 04:57:20 3 1 LINDA WILLIAMS LINDA.WILLIAMS@sakilacustomer.org 7 1 2006-02-14 22:04:36 2006-02-15 04:57:20 CREATE TABLE film ( film_id SMALLINT UNSIGNED NOT NULL, title VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, release_year YEAR DEFAULT NULL, language_id TINYINT UNSIGNED NOT NULL, original_language_id TINYINT UNSIGNED DEFAULT NULL, rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3, rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99, length SMALLINT UNSIGNED DEFAULT NULL, replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99, rating DEFAULT 'G', special_features DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id), FOREIGN KEY (language_id) REFERENCES language (language_id), FOREIGN KEY (original_language_id) REFERENCES language (language_id) ) 3 rows from film table: film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost rating special_features last_update 1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006 1 None 6 0.99 86 20.99 PG Deleted Scenes,Behind the Scenes 2006-02-15 05:03:42 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006 1 None 3 4.99 48 12.99 G Trailers,Deleted Scenes 2006-02-15 05:03:42 3 ADAPTATION HOLES A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory 2006 1 None 7 2.99 50 18.99 NC-17 Trailers,Deleted Scenes 2006-02-15 05:03:42 CREATE TABLE film_actor ( actor_id SMALLINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (actor_id,film_id), FOREIGN KEY (actor_id) REFERENCES actor (actor_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from film_actor table: actor_id film_id last_update 1 1 2006-02-15 05:05:03 1 23 2006-02-15 05:05:03 1 25 2006-02-15 05:05:03 CREATE TABLE film_category ( film_id SMALLINT UNSIGNED NOT NULL, category_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (film_id, category_id), FOREIGN KEY (film_id) REFERENCES film (film_id), FOREIGN KEY (category_id) REFERENCES category (category_id) ) 3 rows from film_category table: film_id category_id last_update 1 6 2006-02-15 05:07:09 2 11 2006-02-15 05:07:09 3 6 2006-02-15 05:07:09 CREATE TABLE film_text ( film_id SMALLINT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT, PRIMARY KEY (film_id) ) 3 rows from film_text table: Empty DataFrame Columns: [film_id, title, description] Index: [] CREATE TABLE inventory ( inventory_id MEDIUMINT UNSIGNED NOT NULL, film_id SMALLINT UNSIGNED NOT NULL, store_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (inventory_id), FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (film_id) REFERENCES film (film_id) ) 3 rows from inventory table: inventory_id film_id store_id last_update 1 1 1 2006-02-15 05:09:17 2 1 1 2006-02-15 05:09:17 3 1 1 2006-02-15 05:09:17 CREATE TABLE language ( language_id TINYINT UNSIGNED NOT NULL, name CHAR(20) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (language_id) ) 3 rows from language table: Empty DataFrame Columns: [language_id, name, last_update] Index: [] CREATE TABLE payment ( payment_id SMALLINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, staff_id TINYINT UNSIGNED NOT NULL, rental_id INT DEFAULT NULL, amount DECIMAL(5,2) NOT NULL, payment_date DATETIME NOT NULL, last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (payment_id), FOREIGN KEY (rental_id) REFERENCES rental (rental_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ) 3 rows from payment table: payment_id customer_id staff_id rental_id amount payment_date last_update 1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30 2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30 3 1 1 1185 5.99 2005-06-15 00:54:12 2006-02-15 22:12:30 CREATE TABLE rental ( rental_id INT NOT NULL, rental_date DATETIME NOT NULL, inventory_id MEDIUMINT UNSIGNED NOT NULL, customer_id SMALLINT UNSIGNED NOT NULL, return_date DATETIME DEFAULT NULL, staff_id TINYINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (rental_id), FOREIGN KEY (staff_id) REFERENCES staff (staff_id), FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id), FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ) 3 rows from rental table: rental_id rental_date inventory_id customer_id return_date staff_id last_update 1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53 2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53 3 2005-05-24 23:03:39 1711 408 2005-06-01 22:12:39 1 2006-02-15 21:30:53 CREATE TABLE staff ( staff_id TINYINT UNSIGNED NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, picture BLOB DEFAULT NULL, email VARCHAR(50) DEFAULT NULL, store_id TINYINT UNSIGNED NOT NULL, active BOOLEAN NOT NULL DEFAULT TRUE, username VARCHAR(16) NOT NULL, password VARCHAR(40) DEFAULT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (staff_id), --FOREIGN KEY (store_id) REFERENCES store (store_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from staff table: Empty DataFrame Columns: [staff_id, first_name, last_name, address_id, picture, email, store_id, active, username, password, last_update] Index: [] CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (store_id), FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id), FOREIGN KEY (address_id) REFERENCES address (address_id) ) 3 rows from store table: Empty DataFrame Columns: [store_id, manager_staff_id, address_id, last_update] Index: []