spider_version
int64
1
2
db_id
stringclasses
204 values
schema
stringclasses
187 values
question
stringlengths
3
328
query
stringlengths
20
3.81k
1
wine_1
CREATE TABLE "grapes" ( "ID" INTEGER PRIMARY KEY, "Grape" TEXT UNIQUE, "Color" TEXT ); CREATE TABLE "appellations" ( "No" INTEGER PRIMARY KEY, "Appelation" TEXT UNIQUE, "County" TEXT, "State" TEXT, "Area" TEXT, "isAVA" TEXT ); CREATE TABLE "wine" ( "No" INTEGER, "Grape" TEXT, "Winery" TEXT, "Appelation" TEXT, "State" TEXT, "Name" TEXT, "Year" INTEGER, "Price" INTEGER, "Score" INTEGER, "Cases" INTEGER, "Drink" TEXT, FOREIGN KEY (Grape) REFERENCES grapes(Grape), FOREIGN KEY (Appelation) REFERENCES appellations(Appelation) )
What are the numbers of wines for different grapes?
SELECT count(*) , Grape FROM WINE GROUP BY Grape
1
wine_1
CREATE TABLE "grapes" ( "ID" INTEGER PRIMARY KEY, "Grape" TEXT UNIQUE, "Color" TEXT ); CREATE TABLE "appellations" ( "No" INTEGER PRIMARY KEY, "Appelation" TEXT UNIQUE, "County" TEXT, "State" TEXT, "Area" TEXT, "isAVA" TEXT ); CREATE TABLE "wine" ( "No" INTEGER, "Grape" TEXT, "Winery" TEXT, "Appelation" TEXT, "State" TEXT, "Name" TEXT, "Year" INTEGER, "Price" INTEGER, "Score" INTEGER, "Cases" INTEGER, "Drink" TEXT, FOREIGN KEY (Grape) REFERENCES grapes(Grape), FOREIGN KEY (Appelation) REFERENCES appellations(Appelation) )
How many wines are there for each grape?
SELECT count(*) , Grape FROM WINE GROUP BY Grape
1
wine_1
CREATE TABLE "grapes" ( "ID" INTEGER PRIMARY KEY, "Grape" TEXT UNIQUE, "Color" TEXT ); CREATE TABLE "appellations" ( "No" INTEGER PRIMARY KEY, "Appelation" TEXT UNIQUE, "County" TEXT, "State" TEXT, "Area" TEXT, "isAVA" TEXT ); CREATE TABLE "wine" ( "No" INTEGER, "Grape" TEXT, "Winery" TEXT, "Appelation" TEXT, "State" TEXT, "Name" TEXT, "Year" INTEGER, "Price" INTEGER, "Score" INTEGER, "Cases" INTEGER, "Drink" TEXT, FOREIGN KEY (Grape) REFERENCES grapes(Grape), FOREIGN KEY (Appelation) REFERENCES appellations(Appelation) )
What are the average prices of wines for different years?
SELECT avg(Price) , YEAR FROM WINE GROUP BY YEAR
1
wine_1
CREATE TABLE "grapes" ( "ID" INTEGER PRIMARY KEY, "Grape" TEXT UNIQUE, "Color" TEXT ); CREATE TABLE "appellations" ( "No" INTEGER PRIMARY KEY, "Appelation" TEXT UNIQUE, "County" TEXT, "State" TEXT, "Area" TEXT, "isAVA" TEXT ); CREATE TABLE "wine" ( "No" INTEGER, "Grape" TEXT, "Winery" TEXT, "Appelation" TEXT, "State" TEXT, "Name" TEXT, "Year" INTEGER, "Price" INTEGER, "Score" INTEGER, "Cases" INTEGER, "Drink" TEXT, FOREIGN KEY (Grape) REFERENCES grapes(Grape), FOREIGN KEY (Appelation) REFERENCES appellations(Appelation) )
What is the average prices of wines for each each?
SELECT avg(Price) , YEAR FROM WINE GROUP BY YEAR
1
wine_1
CREATE TABLE "grapes" ( "ID" INTEGER PRIMARY KEY, "Grape" TEXT UNIQUE, "Color" TEXT ); CREATE TABLE "appellations" ( "No" INTEGER PRIMARY KEY, "Appelation" TEXT UNIQUE, "County" TEXT, "State" TEXT, "Area" TEXT, "isAVA" TEXT ); CREATE TABLE "wine" ( "No" INTEGER, "Grape" TEXT, "Winery" TEXT, "Appelation" TEXT, "State" TEXT, "Name" TEXT, "Year" INTEGER, "Price" INTEGER, "Score" INTEGER, "Cases" INTEGER, "Drink" TEXT, FOREIGN KEY (Grape) REFERENCES grapes(Grape), FOREIGN KEY (Appelation) REFERENCES appellations(Appelation) )
Find the distinct names of all wines that have prices higher than some wines from John Anthony winery.
SELECT DISTINCT Name FROM WINE WHERE Price > (SELECT min(Price) FROM wine WHERE Winery = "John Anthony")
1
wine_1
CREATE TABLE "grapes" ( "ID" INTEGER PRIMARY KEY, "Grape" TEXT UNIQUE, "Color" TEXT ); CREATE TABLE "appellations" ( "No" INTEGER PRIMARY KEY, "Appelation" TEXT UNIQUE, "County" TEXT, "State" TEXT, "Area" TEXT, "isAVA" TEXT ); CREATE TABLE "wine" ( "No" INTEGER, "Grape" TEXT, "Winery" TEXT, "Appelation" TEXT, "State" TEXT, "Name" TEXT, "Year" INTEGER, "Price" INTEGER, "Score" INTEGER, "Cases" INTEGER, "Drink" TEXT, FOREIGN KEY (Grape) REFERENCES grapes(Grape), FOREIGN KEY (Appelation) REFERENCES appellations(Appelation) )
What are the distinct names of wines with prices higher than any wine from John Anthony winery.
SELECT DISTINCT Name FROM WINE WHERE Price > (SELECT min(Price) FROM wine WHERE Winery = "John Anthony")
1
wine_1
CREATE TABLE "grapes" ( "ID" INTEGER PRIMARY KEY, "Grape" TEXT UNIQUE, "Color" TEXT ); CREATE TABLE "appellations" ( "No" INTEGER PRIMARY KEY, "Appelation" TEXT UNIQUE, "County" TEXT, "State" TEXT, "Area" TEXT, "isAVA" TEXT ); CREATE TABLE "wine" ( "No" INTEGER, "Grape" TEXT, "Winery" TEXT, "Appelation" TEXT, "State" TEXT, "Name" TEXT, "Year" INTEGER, "Price" INTEGER, "Score" INTEGER, "Cases" INTEGER, "Drink" TEXT, FOREIGN KEY (Grape) REFERENCES grapes(Grape), FOREIGN KEY (Appelation) REFERENCES appellations(Appelation) )
List the names of all distinct wines in alphabetical order.
SELECT DISTINCT Name FROM WINE ORDER BY Name
1
wine_1
CREATE TABLE "grapes" ( "ID" INTEGER PRIMARY KEY, "Grape" TEXT UNIQUE, "Color" TEXT ); CREATE TABLE "appellations" ( "No" INTEGER PRIMARY KEY, "Appelation" TEXT UNIQUE, "County" TEXT, "State" TEXT, "Area" TEXT, "isAVA" TEXT ); CREATE TABLE "wine" ( "No" INTEGER, "Grape" TEXT, "Winery" TEXT, "Appelation" TEXT, "State" TEXT, "Name" TEXT, "Year" INTEGER, "Price" INTEGER, "Score" INTEGER, "Cases" INTEGER, "Drink" TEXT, FOREIGN KEY (Grape) REFERENCES grapes(Grape), FOREIGN KEY (Appelation) REFERENCES appellations(Appelation) )
What are the names of wines, sorted in alphabetical order?
SELECT DISTINCT Name FROM WINE ORDER BY Name
1
wine_1
CREATE TABLE "grapes" ( "ID" INTEGER PRIMARY KEY, "Grape" TEXT UNIQUE, "Color" TEXT ); CREATE TABLE "appellations" ( "No" INTEGER PRIMARY KEY, "Appelation" TEXT UNIQUE, "County" TEXT, "State" TEXT, "Area" TEXT, "isAVA" TEXT ); CREATE TABLE "wine" ( "No" INTEGER, "Grape" TEXT, "Winery" TEXT, "Appelation" TEXT, "State" TEXT, "Name" TEXT, "Year" INTEGER, "Price" INTEGER, "Score" INTEGER, "Cases" INTEGER, "Drink" TEXT, FOREIGN KEY (Grape) REFERENCES grapes(Grape), FOREIGN KEY (Appelation) REFERENCES appellations(Appelation) )
List the names of all distinct wines ordered by price.
SELECT DISTINCT Name FROM WINE ORDER BY price
1
wine_1
CREATE TABLE "grapes" ( "ID" INTEGER PRIMARY KEY, "Grape" TEXT UNIQUE, "Color" TEXT ); CREATE TABLE "appellations" ( "No" INTEGER PRIMARY KEY, "Appelation" TEXT UNIQUE, "County" TEXT, "State" TEXT, "Area" TEXT, "isAVA" TEXT ); CREATE TABLE "wine" ( "No" INTEGER, "Grape" TEXT, "Winery" TEXT, "Appelation" TEXT, "State" TEXT, "Name" TEXT, "Year" INTEGER, "Price" INTEGER, "Score" INTEGER, "Cases" INTEGER, "Drink" TEXT, FOREIGN KEY (Grape) REFERENCES grapes(Grape), FOREIGN KEY (Appelation) REFERENCES appellations(Appelation) )
What are the names of wines, sorted by price ascending?
SELECT DISTINCT Name FROM WINE ORDER BY price
1
wine_1
CREATE TABLE "grapes" ( "ID" INTEGER PRIMARY KEY, "Grape" TEXT UNIQUE, "Color" TEXT ); CREATE TABLE "appellations" ( "No" INTEGER PRIMARY KEY, "Appelation" TEXT UNIQUE, "County" TEXT, "State" TEXT, "Area" TEXT, "isAVA" TEXT ); CREATE TABLE "wine" ( "No" INTEGER, "Grape" TEXT, "Winery" TEXT, "Appelation" TEXT, "State" TEXT, "Name" TEXT, "Year" INTEGER, "Price" INTEGER, "Score" INTEGER, "Cases" INTEGER, "Drink" TEXT, FOREIGN KEY (Grape) REFERENCES grapes(Grape), FOREIGN KEY (Appelation) REFERENCES appellations(Appelation) )
What is the area of the appelation that produces the highest number of wines before the year of 2010?
SELECT T1.Area FROM APPELLATIONS AS T1 JOIN WINE AS T2 ON T1.Appelation = T2.Appelation GROUP BY T2.Appelation HAVING T2.year < 2010 ORDER BY count(*) DESC LIMIT 1
1
wine_1
CREATE TABLE "grapes" ( "ID" INTEGER PRIMARY KEY, "Grape" TEXT UNIQUE, "Color" TEXT ); CREATE TABLE "appellations" ( "No" INTEGER PRIMARY KEY, "Appelation" TEXT UNIQUE, "County" TEXT, "State" TEXT, "Area" TEXT, "isAVA" TEXT ); CREATE TABLE "wine" ( "No" INTEGER, "Grape" TEXT, "Winery" TEXT, "Appelation" TEXT, "State" TEXT, "Name" TEXT, "Year" INTEGER, "Price" INTEGER, "Score" INTEGER, "Cases" INTEGER, "Drink" TEXT, FOREIGN KEY (Grape) REFERENCES grapes(Grape), FOREIGN KEY (Appelation) REFERENCES appellations(Appelation) )
What is the area for the appelation which produced the most wines prior to 2010?
SELECT T1.Area FROM APPELLATIONS AS T1 JOIN WINE AS T2 ON T1.Appelation = T2.Appelation GROUP BY T2.Appelation HAVING T2.year < 2010 ORDER BY count(*) DESC LIMIT 1
1
wine_1
CREATE TABLE "grapes" ( "ID" INTEGER PRIMARY KEY, "Grape" TEXT UNIQUE, "Color" TEXT ); CREATE TABLE "appellations" ( "No" INTEGER PRIMARY KEY, "Appelation" TEXT UNIQUE, "County" TEXT, "State" TEXT, "Area" TEXT, "isAVA" TEXT ); CREATE TABLE "wine" ( "No" INTEGER, "Grape" TEXT, "Winery" TEXT, "Appelation" TEXT, "State" TEXT, "Name" TEXT, "Year" INTEGER, "Price" INTEGER, "Score" INTEGER, "Cases" INTEGER, "Drink" TEXT, FOREIGN KEY (Grape) REFERENCES grapes(Grape), FOREIGN KEY (Appelation) REFERENCES appellations(Appelation) )
What is the color of the grape whose wine products has the highest average price?
SELECT T1.Color FROM GRAPES AS T1 JOIN WINE AS T2 ON T1.Grape = T2.Grape GROUP BY T2.Grape ORDER BY AVG(Price) DESC LIMIT 1
1
wine_1
CREATE TABLE "grapes" ( "ID" INTEGER PRIMARY KEY, "Grape" TEXT UNIQUE, "Color" TEXT ); CREATE TABLE "appellations" ( "No" INTEGER PRIMARY KEY, "Appelation" TEXT UNIQUE, "County" TEXT, "State" TEXT, "Area" TEXT, "isAVA" TEXT ); CREATE TABLE "wine" ( "No" INTEGER, "Grape" TEXT, "Winery" TEXT, "Appelation" TEXT, "State" TEXT, "Name" TEXT, "Year" INTEGER, "Price" INTEGER, "Score" INTEGER, "Cases" INTEGER, "Drink" TEXT, FOREIGN KEY (Grape) REFERENCES grapes(Grape), FOREIGN KEY (Appelation) REFERENCES appellations(Appelation) )
Give the color of the grape whose wine products have the highest average price?
SELECT T1.Color FROM GRAPES AS T1 JOIN WINE AS T2 ON T1.Grape = T2.Grape GROUP BY T2.Grape ORDER BY AVG(Price) DESC LIMIT 1
1
wine_1
CREATE TABLE "grapes" ( "ID" INTEGER PRIMARY KEY, "Grape" TEXT UNIQUE, "Color" TEXT ); CREATE TABLE "appellations" ( "No" INTEGER PRIMARY KEY, "Appelation" TEXT UNIQUE, "County" TEXT, "State" TEXT, "Area" TEXT, "isAVA" TEXT ); CREATE TABLE "wine" ( "No" INTEGER, "Grape" TEXT, "Winery" TEXT, "Appelation" TEXT, "State" TEXT, "Name" TEXT, "Year" INTEGER, "Price" INTEGER, "Score" INTEGER, "Cases" INTEGER, "Drink" TEXT, FOREIGN KEY (Grape) REFERENCES grapes(Grape), FOREIGN KEY (Appelation) REFERENCES appellations(Appelation) )
Find the distinct names of wines produced before the year of 2000 or after the year of 2010.
SELECT DISTINCT Name FROM WINE WHERE YEAR < 2000 OR YEAR > 2010
1
wine_1
CREATE TABLE "grapes" ( "ID" INTEGER PRIMARY KEY, "Grape" TEXT UNIQUE, "Color" TEXT ); CREATE TABLE "appellations" ( "No" INTEGER PRIMARY KEY, "Appelation" TEXT UNIQUE, "County" TEXT, "State" TEXT, "Area" TEXT, "isAVA" TEXT ); CREATE TABLE "wine" ( "No" INTEGER, "Grape" TEXT, "Winery" TEXT, "Appelation" TEXT, "State" TEXT, "Name" TEXT, "Year" INTEGER, "Price" INTEGER, "Score" INTEGER, "Cases" INTEGER, "Drink" TEXT, FOREIGN KEY (Grape) REFERENCES grapes(Grape), FOREIGN KEY (Appelation) REFERENCES appellations(Appelation) )
Give the distinct names of wines made before 2000 or after 2010.
SELECT DISTINCT Name FROM WINE WHERE YEAR < 2000 OR YEAR > 2010
1
wine_1
CREATE TABLE "grapes" ( "ID" INTEGER PRIMARY KEY, "Grape" TEXT UNIQUE, "Color" TEXT ); CREATE TABLE "appellations" ( "No" INTEGER PRIMARY KEY, "Appelation" TEXT UNIQUE, "County" TEXT, "State" TEXT, "Area" TEXT, "isAVA" TEXT ); CREATE TABLE "wine" ( "No" INTEGER, "Grape" TEXT, "Winery" TEXT, "Appelation" TEXT, "State" TEXT, "Name" TEXT, "Year" INTEGER, "Price" INTEGER, "Score" INTEGER, "Cases" INTEGER, "Drink" TEXT, FOREIGN KEY (Grape) REFERENCES grapes(Grape), FOREIGN KEY (Appelation) REFERENCES appellations(Appelation) )
Find the distinct winery of wines having price between 50 and 100.
SELECT DISTINCT Winery FROM WINE WHERE Price BETWEEN 50 AND 100
1
wine_1
CREATE TABLE "grapes" ( "ID" INTEGER PRIMARY KEY, "Grape" TEXT UNIQUE, "Color" TEXT ); CREATE TABLE "appellations" ( "No" INTEGER PRIMARY KEY, "Appelation" TEXT UNIQUE, "County" TEXT, "State" TEXT, "Area" TEXT, "isAVA" TEXT ); CREATE TABLE "wine" ( "No" INTEGER, "Grape" TEXT, "Winery" TEXT, "Appelation" TEXT, "State" TEXT, "Name" TEXT, "Year" INTEGER, "Price" INTEGER, "Score" INTEGER, "Cases" INTEGER, "Drink" TEXT, FOREIGN KEY (Grape) REFERENCES grapes(Grape), FOREIGN KEY (Appelation) REFERENCES appellations(Appelation) )
What are the distinct wineries which produce wines costing between 50 and 100?
SELECT DISTINCT Winery FROM WINE WHERE Price BETWEEN 50 AND 100
1
wine_1
CREATE TABLE "grapes" ( "ID" INTEGER PRIMARY KEY, "Grape" TEXT UNIQUE, "Color" TEXT ); CREATE TABLE "appellations" ( "No" INTEGER PRIMARY KEY, "Appelation" TEXT UNIQUE, "County" TEXT, "State" TEXT, "Area" TEXT, "isAVA" TEXT ); CREATE TABLE "wine" ( "No" INTEGER, "Grape" TEXT, "Winery" TEXT, "Appelation" TEXT, "State" TEXT, "Name" TEXT, "Year" INTEGER, "Price" INTEGER, "Score" INTEGER, "Cases" INTEGER, "Drink" TEXT, FOREIGN KEY (Grape) REFERENCES grapes(Grape), FOREIGN KEY (Appelation) REFERENCES appellations(Appelation) )
What are the average prices and cases of wines produced in the year of 2009 and made of Zinfandel grape?
SELECT AVG(Price) , AVG(Cases) FROM WINE WHERE YEAR = 2009 AND Grape = "Zinfandel"
1
wine_1
CREATE TABLE "grapes" ( "ID" INTEGER PRIMARY KEY, "Grape" TEXT UNIQUE, "Color" TEXT ); CREATE TABLE "appellations" ( "No" INTEGER PRIMARY KEY, "Appelation" TEXT UNIQUE, "County" TEXT, "State" TEXT, "Area" TEXT, "isAVA" TEXT ); CREATE TABLE "wine" ( "No" INTEGER, "Grape" TEXT, "Winery" TEXT, "Appelation" TEXT, "State" TEXT, "Name" TEXT, "Year" INTEGER, "Price" INTEGER, "Score" INTEGER, "Cases" INTEGER, "Drink" TEXT, FOREIGN KEY (Grape) REFERENCES grapes(Grape), FOREIGN KEY (Appelation) REFERENCES appellations(Appelation) )
Give the average price and case of wines made from Zinfandel grapes in the year 2009.
SELECT AVG(Price) , AVG(Cases) FROM WINE WHERE YEAR = 2009 AND Grape = "Zinfandel"
1
wine_1
CREATE TABLE "grapes" ( "ID" INTEGER PRIMARY KEY, "Grape" TEXT UNIQUE, "Color" TEXT ); CREATE TABLE "appellations" ( "No" INTEGER PRIMARY KEY, "Appelation" TEXT UNIQUE, "County" TEXT, "State" TEXT, "Area" TEXT, "isAVA" TEXT ); CREATE TABLE "wine" ( "No" INTEGER, "Grape" TEXT, "Winery" TEXT, "Appelation" TEXT, "State" TEXT, "Name" TEXT, "Year" INTEGER, "Price" INTEGER, "Score" INTEGER, "Cases" INTEGER, "Drink" TEXT, FOREIGN KEY (Grape) REFERENCES grapes(Grape), FOREIGN KEY (Appelation) REFERENCES appellations(Appelation) )
What are the maximum price and score of wines produced by St. Helena appelation?
SELECT max(Price) , max(Score) FROM WINE WHERE Appelation = "St. Helena"
1
wine_1
CREATE TABLE "grapes" ( "ID" INTEGER PRIMARY KEY, "Grape" TEXT UNIQUE, "Color" TEXT ); CREATE TABLE "appellations" ( "No" INTEGER PRIMARY KEY, "Appelation" TEXT UNIQUE, "County" TEXT, "State" TEXT, "Area" TEXT, "isAVA" TEXT ); CREATE TABLE "wine" ( "No" INTEGER, "Grape" TEXT, "Winery" TEXT, "Appelation" TEXT, "State" TEXT, "Name" TEXT, "Year" INTEGER, "Price" INTEGER, "Score" INTEGER, "Cases" INTEGER, "Drink" TEXT, FOREIGN KEY (Grape) REFERENCES grapes(Grape), FOREIGN KEY (Appelation) REFERENCES appellations(Appelation) )
Give the maximum price and score for wines produced in the appelation St. Helena.
SELECT max(Price) , max(Score) FROM WINE WHERE Appelation = "St. Helena"
1
wine_1
CREATE TABLE "grapes" ( "ID" INTEGER PRIMARY KEY, "Grape" TEXT UNIQUE, "Color" TEXT ); CREATE TABLE "appellations" ( "No" INTEGER PRIMARY KEY, "Appelation" TEXT UNIQUE, "County" TEXT, "State" TEXT, "Area" TEXT, "isAVA" TEXT ); CREATE TABLE "wine" ( "No" INTEGER, "Grape" TEXT, "Winery" TEXT, "Appelation" TEXT, "State" TEXT, "Name" TEXT, "Year" INTEGER, "Price" INTEGER, "Score" INTEGER, "Cases" INTEGER, "Drink" TEXT, FOREIGN KEY (Grape) REFERENCES grapes(Grape), FOREIGN KEY (Appelation) REFERENCES appellations(Appelation) )
What are the maximum price and score of wines in each year?
SELECT max(Price) , max(Score) , YEAR FROM WINE GROUP BY YEAR
1
wine_1
CREATE TABLE "grapes" ( "ID" INTEGER PRIMARY KEY, "Grape" TEXT UNIQUE, "Color" TEXT ); CREATE TABLE "appellations" ( "No" INTEGER PRIMARY KEY, "Appelation" TEXT UNIQUE, "County" TEXT, "State" TEXT, "Area" TEXT, "isAVA" TEXT ); CREATE TABLE "wine" ( "No" INTEGER, "Grape" TEXT, "Winery" TEXT, "Appelation" TEXT, "State" TEXT, "Name" TEXT, "Year" INTEGER, "Price" INTEGER, "Score" INTEGER, "Cases" INTEGER, "Drink" TEXT, FOREIGN KEY (Grape) REFERENCES grapes(Grape), FOREIGN KEY (Appelation) REFERENCES appellations(Appelation) )
What are the maximum price and score of wines for each year?
SELECT max(Price) , max(Score) , YEAR FROM WINE GROUP BY YEAR
1
wine_1
CREATE TABLE "grapes" ( "ID" INTEGER PRIMARY KEY, "Grape" TEXT UNIQUE, "Color" TEXT ); CREATE TABLE "appellations" ( "No" INTEGER PRIMARY KEY, "Appelation" TEXT UNIQUE, "County" TEXT, "State" TEXT, "Area" TEXT, "isAVA" TEXT ); CREATE TABLE "wine" ( "No" INTEGER, "Grape" TEXT, "Winery" TEXT, "Appelation" TEXT, "State" TEXT, "Name" TEXT, "Year" INTEGER, "Price" INTEGER, "Score" INTEGER, "Cases" INTEGER, "Drink" TEXT, FOREIGN KEY (Grape) REFERENCES grapes(Grape), FOREIGN KEY (Appelation) REFERENCES appellations(Appelation) )
What are the average price and score of wines grouped by appelation?
SELECT avg(Price) , avg(Score) , Appelation FROM WINE GROUP BY Appelation
1
wine_1
CREATE TABLE "grapes" ( "ID" INTEGER PRIMARY KEY, "Grape" TEXT UNIQUE, "Color" TEXT ); CREATE TABLE "appellations" ( "No" INTEGER PRIMARY KEY, "Appelation" TEXT UNIQUE, "County" TEXT, "State" TEXT, "Area" TEXT, "isAVA" TEXT ); CREATE TABLE "wine" ( "No" INTEGER, "Grape" TEXT, "Winery" TEXT, "Appelation" TEXT, "State" TEXT, "Name" TEXT, "Year" INTEGER, "Price" INTEGER, "Score" INTEGER, "Cases" INTEGER, "Drink" TEXT, FOREIGN KEY (Grape) REFERENCES grapes(Grape), FOREIGN KEY (Appelation) REFERENCES appellations(Appelation) )
What are the average price and score of wines for each appelation?
SELECT avg(Price) , avg(Score) , Appelation FROM WINE GROUP BY Appelation
1
wine_1
CREATE TABLE "grapes" ( "ID" INTEGER PRIMARY KEY, "Grape" TEXT UNIQUE, "Color" TEXT ); CREATE TABLE "appellations" ( "No" INTEGER PRIMARY KEY, "Appelation" TEXT UNIQUE, "County" TEXT, "State" TEXT, "Area" TEXT, "isAVA" TEXT ); CREATE TABLE "wine" ( "No" INTEGER, "Grape" TEXT, "Winery" TEXT, "Appelation" TEXT, "State" TEXT, "Name" TEXT, "Year" INTEGER, "Price" INTEGER, "Score" INTEGER, "Cases" INTEGER, "Drink" TEXT, FOREIGN KEY (Grape) REFERENCES grapes(Grape), FOREIGN KEY (Appelation) REFERENCES appellations(Appelation) )
Find the wineries that have at least four wines.
SELECT Winery FROM WINE GROUP BY Winery HAVING count(*) >= 4
1
wine_1
CREATE TABLE "grapes" ( "ID" INTEGER PRIMARY KEY, "Grape" TEXT UNIQUE, "Color" TEXT ); CREATE TABLE "appellations" ( "No" INTEGER PRIMARY KEY, "Appelation" TEXT UNIQUE, "County" TEXT, "State" TEXT, "Area" TEXT, "isAVA" TEXT ); CREATE TABLE "wine" ( "No" INTEGER, "Grape" TEXT, "Winery" TEXT, "Appelation" TEXT, "State" TEXT, "Name" TEXT, "Year" INTEGER, "Price" INTEGER, "Score" INTEGER, "Cases" INTEGER, "Drink" TEXT, FOREIGN KEY (Grape) REFERENCES grapes(Grape), FOREIGN KEY (Appelation) REFERENCES appellations(Appelation) )
Which wineries produce at least four wines?
SELECT Winery FROM WINE GROUP BY Winery HAVING count(*) >= 4
1
wine_1
CREATE TABLE "grapes" ( "ID" INTEGER PRIMARY KEY, "Grape" TEXT UNIQUE, "Color" TEXT ); CREATE TABLE "appellations" ( "No" INTEGER PRIMARY KEY, "Appelation" TEXT UNIQUE, "County" TEXT, "State" TEXT, "Area" TEXT, "isAVA" TEXT ); CREATE TABLE "wine" ( "No" INTEGER, "Grape" TEXT, "Winery" TEXT, "Appelation" TEXT, "State" TEXT, "Name" TEXT, "Year" INTEGER, "Price" INTEGER, "Score" INTEGER, "Cases" INTEGER, "Drink" TEXT, FOREIGN KEY (Grape) REFERENCES grapes(Grape), FOREIGN KEY (Appelation) REFERENCES appellations(Appelation) )
Find the country of all appelations who have at most three wines.
SELECT T1.County FROM APPELLATIONS AS T1 JOIN WINE AS T2 ON T1.Appelation = T2.Appelation GROUP BY T2.Appelation HAVING count(*) <= 3
1
wine_1
CREATE TABLE "grapes" ( "ID" INTEGER PRIMARY KEY, "Grape" TEXT UNIQUE, "Color" TEXT ); CREATE TABLE "appellations" ( "No" INTEGER PRIMARY KEY, "Appelation" TEXT UNIQUE, "County" TEXT, "State" TEXT, "Area" TEXT, "isAVA" TEXT ); CREATE TABLE "wine" ( "No" INTEGER, "Grape" TEXT, "Winery" TEXT, "Appelation" TEXT, "State" TEXT, "Name" TEXT, "Year" INTEGER, "Price" INTEGER, "Score" INTEGER, "Cases" INTEGER, "Drink" TEXT, FOREIGN KEY (Grape) REFERENCES grapes(Grape), FOREIGN KEY (Appelation) REFERENCES appellations(Appelation) )
What are the countries for appelations with at most 3 wines?
SELECT T1.County FROM APPELLATIONS AS T1 JOIN WINE AS T2 ON T1.Appelation = T2.Appelation GROUP BY T2.Appelation HAVING count(*) <= 3
1
wine_1
CREATE TABLE "grapes" ( "ID" INTEGER PRIMARY KEY, "Grape" TEXT UNIQUE, "Color" TEXT ); CREATE TABLE "appellations" ( "No" INTEGER PRIMARY KEY, "Appelation" TEXT UNIQUE, "County" TEXT, "State" TEXT, "Area" TEXT, "isAVA" TEXT ); CREATE TABLE "wine" ( "No" INTEGER, "Grape" TEXT, "Winery" TEXT, "Appelation" TEXT, "State" TEXT, "Name" TEXT, "Year" INTEGER, "Price" INTEGER, "Score" INTEGER, "Cases" INTEGER, "Drink" TEXT, FOREIGN KEY (Grape) REFERENCES grapes(Grape), FOREIGN KEY (Appelation) REFERENCES appellations(Appelation) )
What are the names of wines whose production year are before the year of all wines by Brander winery?
SELECT Name FROM WINE WHERE YEAR < (SELECT min(YEAR) FROM WINE WHERE Winery = "Brander")
1
wine_1
CREATE TABLE "grapes" ( "ID" INTEGER PRIMARY KEY, "Grape" TEXT UNIQUE, "Color" TEXT ); CREATE TABLE "appellations" ( "No" INTEGER PRIMARY KEY, "Appelation" TEXT UNIQUE, "County" TEXT, "State" TEXT, "Area" TEXT, "isAVA" TEXT ); CREATE TABLE "wine" ( "No" INTEGER, "Grape" TEXT, "Winery" TEXT, "Appelation" TEXT, "State" TEXT, "Name" TEXT, "Year" INTEGER, "Price" INTEGER, "Score" INTEGER, "Cases" INTEGER, "Drink" TEXT, FOREIGN KEY (Grape) REFERENCES grapes(Grape), FOREIGN KEY (Appelation) REFERENCES appellations(Appelation) )
What are the names of wines produced before any wine from the Brander winery?
SELECT Name FROM WINE WHERE YEAR < (SELECT min(YEAR) FROM WINE WHERE Winery = "Brander")
1
wine_1
CREATE TABLE "grapes" ( "ID" INTEGER PRIMARY KEY, "Grape" TEXT UNIQUE, "Color" TEXT ); CREATE TABLE "appellations" ( "No" INTEGER PRIMARY KEY, "Appelation" TEXT UNIQUE, "County" TEXT, "State" TEXT, "Area" TEXT, "isAVA" TEXT ); CREATE TABLE "wine" ( "No" INTEGER, "Grape" TEXT, "Winery" TEXT, "Appelation" TEXT, "State" TEXT, "Name" TEXT, "Year" INTEGER, "Price" INTEGER, "Score" INTEGER, "Cases" INTEGER, "Drink" TEXT, FOREIGN KEY (Grape) REFERENCES grapes(Grape), FOREIGN KEY (Appelation) REFERENCES appellations(Appelation) )
What are the names of wines that are more expensive then all wines made in the year 2006?
SELECT Name FROM WINE WHERE Price > (SELECT max(Price) FROM WINE WHERE YEAR = 2006)
1
wine_1
CREATE TABLE "grapes" ( "ID" INTEGER PRIMARY KEY, "Grape" TEXT UNIQUE, "Color" TEXT ); CREATE TABLE "appellations" ( "No" INTEGER PRIMARY KEY, "Appelation" TEXT UNIQUE, "County" TEXT, "State" TEXT, "Area" TEXT, "isAVA" TEXT ); CREATE TABLE "wine" ( "No" INTEGER, "Grape" TEXT, "Winery" TEXT, "Appelation" TEXT, "State" TEXT, "Name" TEXT, "Year" INTEGER, "Price" INTEGER, "Score" INTEGER, "Cases" INTEGER, "Drink" TEXT, FOREIGN KEY (Grape) REFERENCES grapes(Grape), FOREIGN KEY (Appelation) REFERENCES appellations(Appelation) )
Give the names of wines with prices above any wine produced in 2006.
SELECT Name FROM WINE WHERE Price > (SELECT max(Price) FROM WINE WHERE YEAR = 2006)
1
wine_1
CREATE TABLE "grapes" ( "ID" INTEGER PRIMARY KEY, "Grape" TEXT UNIQUE, "Color" TEXT ); CREATE TABLE "appellations" ( "No" INTEGER PRIMARY KEY, "Appelation" TEXT UNIQUE, "County" TEXT, "State" TEXT, "Area" TEXT, "isAVA" TEXT ); CREATE TABLE "wine" ( "No" INTEGER, "Grape" TEXT, "Winery" TEXT, "Appelation" TEXT, "State" TEXT, "Name" TEXT, "Year" INTEGER, "Price" INTEGER, "Score" INTEGER, "Cases" INTEGER, "Drink" TEXT, FOREIGN KEY (Grape) REFERENCES grapes(Grape), FOREIGN KEY (Appelation) REFERENCES appellations(Appelation) )
Find the top 3 wineries with the greatest number of wines made of white color grapes.
SELECT T2.Winery FROM GRAPES AS T1 JOIN WINE AS T2 ON T1.GRAPE = T2.GRAPE WHERE T1.Color = "White" GROUP BY T2.Winery ORDER BY count(*) DESC LIMIT 3
1
wine_1
CREATE TABLE "grapes" ( "ID" INTEGER PRIMARY KEY, "Grape" TEXT UNIQUE, "Color" TEXT ); CREATE TABLE "appellations" ( "No" INTEGER PRIMARY KEY, "Appelation" TEXT UNIQUE, "County" TEXT, "State" TEXT, "Area" TEXT, "isAVA" TEXT ); CREATE TABLE "wine" ( "No" INTEGER, "Grape" TEXT, "Winery" TEXT, "Appelation" TEXT, "State" TEXT, "Name" TEXT, "Year" INTEGER, "Price" INTEGER, "Score" INTEGER, "Cases" INTEGER, "Drink" TEXT, FOREIGN KEY (Grape) REFERENCES grapes(Grape), FOREIGN KEY (Appelation) REFERENCES appellations(Appelation) )
Which 3 wineries produce the most wines made from white grapes?
SELECT T2.Winery FROM GRAPES AS T1 JOIN WINE AS T2 ON T1.GRAPE = T2.GRAPE WHERE T1.Color = "White" GROUP BY T2.Winery ORDER BY count(*) DESC LIMIT 3
1
wine_1
CREATE TABLE "grapes" ( "ID" INTEGER PRIMARY KEY, "Grape" TEXT UNIQUE, "Color" TEXT ); CREATE TABLE "appellations" ( "No" INTEGER PRIMARY KEY, "Appelation" TEXT UNIQUE, "County" TEXT, "State" TEXT, "Area" TEXT, "isAVA" TEXT ); CREATE TABLE "wine" ( "No" INTEGER, "Grape" TEXT, "Winery" TEXT, "Appelation" TEXT, "State" TEXT, "Name" TEXT, "Year" INTEGER, "Price" INTEGER, "Score" INTEGER, "Cases" INTEGER, "Drink" TEXT, FOREIGN KEY (Grape) REFERENCES grapes(Grape), FOREIGN KEY (Appelation) REFERENCES appellations(Appelation) )
List the grape, winery and year of the wines whose price is bigger than 100 ordered by year.
SELECT Grape , Winery , YEAR FROM WINE WHERE Price > 100 ORDER BY YEAR
1
wine_1
CREATE TABLE "grapes" ( "ID" INTEGER PRIMARY KEY, "Grape" TEXT UNIQUE, "Color" TEXT ); CREATE TABLE "appellations" ( "No" INTEGER PRIMARY KEY, "Appelation" TEXT UNIQUE, "County" TEXT, "State" TEXT, "Area" TEXT, "isAVA" TEXT ); CREATE TABLE "wine" ( "No" INTEGER, "Grape" TEXT, "Winery" TEXT, "Appelation" TEXT, "State" TEXT, "Name" TEXT, "Year" INTEGER, "Price" INTEGER, "Score" INTEGER, "Cases" INTEGER, "Drink" TEXT, FOREIGN KEY (Grape) REFERENCES grapes(Grape), FOREIGN KEY (Appelation) REFERENCES appellations(Appelation) )
What are the grapes, wineries and years for wines with price higher than 100, sorted by year?
SELECT Grape , Winery , YEAR FROM WINE WHERE Price > 100 ORDER BY YEAR
1
wine_1
CREATE TABLE "grapes" ( "ID" INTEGER PRIMARY KEY, "Grape" TEXT UNIQUE, "Color" TEXT ); CREATE TABLE "appellations" ( "No" INTEGER PRIMARY KEY, "Appelation" TEXT UNIQUE, "County" TEXT, "State" TEXT, "Area" TEXT, "isAVA" TEXT ); CREATE TABLE "wine" ( "No" INTEGER, "Grape" TEXT, "Winery" TEXT, "Appelation" TEXT, "State" TEXT, "Name" TEXT, "Year" INTEGER, "Price" INTEGER, "Score" INTEGER, "Cases" INTEGER, "Drink" TEXT, FOREIGN KEY (Grape) REFERENCES grapes(Grape), FOREIGN KEY (Appelation) REFERENCES appellations(Appelation) )
List the grape, appelation and name of wines whose score is higher than 93 ordered by Name.
SELECT Grape , Appelation , Name FROM WINE WHERE Score > 93 ORDER BY Name
1
wine_1
CREATE TABLE "grapes" ( "ID" INTEGER PRIMARY KEY, "Grape" TEXT UNIQUE, "Color" TEXT ); CREATE TABLE "appellations" ( "No" INTEGER PRIMARY KEY, "Appelation" TEXT UNIQUE, "County" TEXT, "State" TEXT, "Area" TEXT, "isAVA" TEXT ); CREATE TABLE "wine" ( "No" INTEGER, "Grape" TEXT, "Winery" TEXT, "Appelation" TEXT, "State" TEXT, "Name" TEXT, "Year" INTEGER, "Price" INTEGER, "Score" INTEGER, "Cases" INTEGER, "Drink" TEXT, FOREIGN KEY (Grape) REFERENCES grapes(Grape), FOREIGN KEY (Appelation) REFERENCES appellations(Appelation) )
What are the grapes, appelations, and wines with scores above 93, sorted by Name?
SELECT Grape , Appelation , Name FROM WINE WHERE Score > 93 ORDER BY Name
1
wine_1
CREATE TABLE "grapes" ( "ID" INTEGER PRIMARY KEY, "Grape" TEXT UNIQUE, "Color" TEXT ); CREATE TABLE "appellations" ( "No" INTEGER PRIMARY KEY, "Appelation" TEXT UNIQUE, "County" TEXT, "State" TEXT, "Area" TEXT, "isAVA" TEXT ); CREATE TABLE "wine" ( "No" INTEGER, "Grape" TEXT, "Winery" TEXT, "Appelation" TEXT, "State" TEXT, "Name" TEXT, "Year" INTEGER, "Price" INTEGER, "Score" INTEGER, "Cases" INTEGER, "Drink" TEXT, FOREIGN KEY (Grape) REFERENCES grapes(Grape), FOREIGN KEY (Appelation) REFERENCES appellations(Appelation) )
Find the appelations that produce wines after the year of 2008 but not in Central Coast area.
SELECT Appelation FROM WINE WHERE YEAR > 2008 EXCEPT SELECT Appelation FROM APPELLATIONS WHERE Area = "Central Coast"
1
wine_1
CREATE TABLE "grapes" ( "ID" INTEGER PRIMARY KEY, "Grape" TEXT UNIQUE, "Color" TEXT ); CREATE TABLE "appellations" ( "No" INTEGER PRIMARY KEY, "Appelation" TEXT UNIQUE, "County" TEXT, "State" TEXT, "Area" TEXT, "isAVA" TEXT ); CREATE TABLE "wine" ( "No" INTEGER, "Grape" TEXT, "Winery" TEXT, "Appelation" TEXT, "State" TEXT, "Name" TEXT, "Year" INTEGER, "Price" INTEGER, "Score" INTEGER, "Cases" INTEGER, "Drink" TEXT, FOREIGN KEY (Grape) REFERENCES grapes(Grape), FOREIGN KEY (Appelation) REFERENCES appellations(Appelation) )
What are the appelations for wines produced after 2008 but not in the Central Coast area?
SELECT Appelation FROM WINE WHERE YEAR > 2008 EXCEPT SELECT Appelation FROM APPELLATIONS WHERE Area = "Central Coast"
1
wine_1
CREATE TABLE "grapes" ( "ID" INTEGER PRIMARY KEY, "Grape" TEXT UNIQUE, "Color" TEXT ); CREATE TABLE "appellations" ( "No" INTEGER PRIMARY KEY, "Appelation" TEXT UNIQUE, "County" TEXT, "State" TEXT, "Area" TEXT, "isAVA" TEXT ); CREATE TABLE "wine" ( "No" INTEGER, "Grape" TEXT, "Winery" TEXT, "Appelation" TEXT, "State" TEXT, "Name" TEXT, "Year" INTEGER, "Price" INTEGER, "Score" INTEGER, "Cases" INTEGER, "Drink" TEXT, FOREIGN KEY (Grape) REFERENCES grapes(Grape), FOREIGN KEY (Appelation) REFERENCES appellations(Appelation) )
Find the average price of wines that are not produced from Sonoma county.
SELECT avg(price) FROM wine WHERE Appelation NOT IN (SELECT T1.Appelation FROM APPELLATIONS AS T1 JOIN WINE AS T2 ON T1.Appelation = T2.Appelation WHERE T1.County = 'Sonoma')
1
wine_1
CREATE TABLE "grapes" ( "ID" INTEGER PRIMARY KEY, "Grape" TEXT UNIQUE, "Color" TEXT ); CREATE TABLE "appellations" ( "No" INTEGER PRIMARY KEY, "Appelation" TEXT UNIQUE, "County" TEXT, "State" TEXT, "Area" TEXT, "isAVA" TEXT ); CREATE TABLE "wine" ( "No" INTEGER, "Grape" TEXT, "Winery" TEXT, "Appelation" TEXT, "State" TEXT, "Name" TEXT, "Year" INTEGER, "Price" INTEGER, "Score" INTEGER, "Cases" INTEGER, "Drink" TEXT, FOREIGN KEY (Grape) REFERENCES grapes(Grape), FOREIGN KEY (Appelation) REFERENCES appellations(Appelation) )
What is the average price for wines not produced in Sonoma county?
SELECT avg(price) FROM wine WHERE Appelation NOT IN (SELECT T1.Appelation FROM APPELLATIONS AS T1 JOIN WINE AS T2 ON T1.Appelation = T2.Appelation WHERE T1.County = 'Sonoma')
1
wine_1
CREATE TABLE "grapes" ( "ID" INTEGER PRIMARY KEY, "Grape" TEXT UNIQUE, "Color" TEXT ); CREATE TABLE "appellations" ( "No" INTEGER PRIMARY KEY, "Appelation" TEXT UNIQUE, "County" TEXT, "State" TEXT, "Area" TEXT, "isAVA" TEXT ); CREATE TABLE "wine" ( "No" INTEGER, "Grape" TEXT, "Winery" TEXT, "Appelation" TEXT, "State" TEXT, "Name" TEXT, "Year" INTEGER, "Price" INTEGER, "Score" INTEGER, "Cases" INTEGER, "Drink" TEXT, FOREIGN KEY (Grape) REFERENCES grapes(Grape), FOREIGN KEY (Appelation) REFERENCES appellations(Appelation) )
Find the county where produces the most number of wines with score higher than 90.
SELECT T1.County FROM APPELLATIONS AS T1 JOIN WINE AS T2 ON T1.Appelation = T2.Appelation WHERE T2.Score > 90 GROUP BY T1.County ORDER BY count(*) DESC LIMIT 1
1
wine_1
CREATE TABLE "grapes" ( "ID" INTEGER PRIMARY KEY, "Grape" TEXT UNIQUE, "Color" TEXT ); CREATE TABLE "appellations" ( "No" INTEGER PRIMARY KEY, "Appelation" TEXT UNIQUE, "County" TEXT, "State" TEXT, "Area" TEXT, "isAVA" TEXT ); CREATE TABLE "wine" ( "No" INTEGER, "Grape" TEXT, "Winery" TEXT, "Appelation" TEXT, "State" TEXT, "Name" TEXT, "Year" INTEGER, "Price" INTEGER, "Score" INTEGER, "Cases" INTEGER, "Drink" TEXT, FOREIGN KEY (Grape) REFERENCES grapes(Grape), FOREIGN KEY (Appelation) REFERENCES appellations(Appelation) )
What is the county that produces the most wines scoring higher than 90?
SELECT T1.County FROM APPELLATIONS AS T1 JOIN WINE AS T2 ON T1.Appelation = T2.Appelation WHERE T2.Score > 90 GROUP BY T1.County ORDER BY count(*) DESC LIMIT 1
1
train_station
CREATE TABLE "station" ( "Station_ID" int, "Name" text, "Annual_entry_exit" real, "Annual_interchanges" real, "Total_Passengers" real, "Location" text, "Main_Services" text, "Number_of_Platforms" int, PRIMARY KEY ("Station_ID") ); CREATE TABLE "train" ( "Train_ID" int, "Name" text, "Time" text, "Service" text, PRIMARY KEY ("Train_ID") ); CREATE TABLE "train_station" ( "Train_ID" int, "Station_ID" int, PRIMARY KEY ("Train_ID","Station_ID"), FOREIGN KEY ("Train_ID") REFERENCES "train"("Train_ID"), FOREIGN KEY ("Station_ID") REFERENCES "station"("Station_ID") )
How many train stations are there?
SELECT count(*) FROM station
1
train_station
CREATE TABLE "station" ( "Station_ID" int, "Name" text, "Annual_entry_exit" real, "Annual_interchanges" real, "Total_Passengers" real, "Location" text, "Main_Services" text, "Number_of_Platforms" int, PRIMARY KEY ("Station_ID") ); CREATE TABLE "train" ( "Train_ID" int, "Name" text, "Time" text, "Service" text, PRIMARY KEY ("Train_ID") ); CREATE TABLE "train_station" ( "Train_ID" int, "Station_ID" int, PRIMARY KEY ("Train_ID","Station_ID"), FOREIGN KEY ("Train_ID") REFERENCES "train"("Train_ID"), FOREIGN KEY ("Station_ID") REFERENCES "station"("Station_ID") )
Show the name, location, and number of platforms for all stations.
SELECT name , LOCATION , number_of_platforms FROM station
1
train_station
CREATE TABLE "station" ( "Station_ID" int, "Name" text, "Annual_entry_exit" real, "Annual_interchanges" real, "Total_Passengers" real, "Location" text, "Main_Services" text, "Number_of_Platforms" int, PRIMARY KEY ("Station_ID") ); CREATE TABLE "train" ( "Train_ID" int, "Name" text, "Time" text, "Service" text, PRIMARY KEY ("Train_ID") ); CREATE TABLE "train_station" ( "Train_ID" int, "Station_ID" int, PRIMARY KEY ("Train_ID","Station_ID"), FOREIGN KEY ("Train_ID") REFERENCES "train"("Train_ID"), FOREIGN KEY ("Station_ID") REFERENCES "station"("Station_ID") )
What are all locations of train stations?
SELECT DISTINCT LOCATION FROM station
1
train_station
CREATE TABLE "station" ( "Station_ID" int, "Name" text, "Annual_entry_exit" real, "Annual_interchanges" real, "Total_Passengers" real, "Location" text, "Main_Services" text, "Number_of_Platforms" int, PRIMARY KEY ("Station_ID") ); CREATE TABLE "train" ( "Train_ID" int, "Name" text, "Time" text, "Service" text, PRIMARY KEY ("Train_ID") ); CREATE TABLE "train_station" ( "Train_ID" int, "Station_ID" int, PRIMARY KEY ("Train_ID","Station_ID"), FOREIGN KEY ("Train_ID") REFERENCES "train"("Train_ID"), FOREIGN KEY ("Station_ID") REFERENCES "station"("Station_ID") )
Show the names and total passengers for all train stations not in London.
SELECT name , total_passengers FROM station WHERE LOCATION != 'London'
1
train_station
CREATE TABLE "station" ( "Station_ID" int, "Name" text, "Annual_entry_exit" real, "Annual_interchanges" real, "Total_Passengers" real, "Location" text, "Main_Services" text, "Number_of_Platforms" int, PRIMARY KEY ("Station_ID") ); CREATE TABLE "train" ( "Train_ID" int, "Name" text, "Time" text, "Service" text, PRIMARY KEY ("Train_ID") ); CREATE TABLE "train_station" ( "Train_ID" int, "Station_ID" int, PRIMARY KEY ("Train_ID","Station_ID"), FOREIGN KEY ("Train_ID") REFERENCES "train"("Train_ID"), FOREIGN KEY ("Station_ID") REFERENCES "station"("Station_ID") )
Show the names and main services for train stations that have the top three total number of passengers.
SELECT name , main_services FROM station ORDER BY total_passengers DESC LIMIT 3
1
train_station
CREATE TABLE "station" ( "Station_ID" int, "Name" text, "Annual_entry_exit" real, "Annual_interchanges" real, "Total_Passengers" real, "Location" text, "Main_Services" text, "Number_of_Platforms" int, PRIMARY KEY ("Station_ID") ); CREATE TABLE "train" ( "Train_ID" int, "Name" text, "Time" text, "Service" text, PRIMARY KEY ("Train_ID") ); CREATE TABLE "train_station" ( "Train_ID" int, "Station_ID" int, PRIMARY KEY ("Train_ID","Station_ID"), FOREIGN KEY ("Train_ID") REFERENCES "train"("Train_ID"), FOREIGN KEY ("Station_ID") REFERENCES "station"("Station_ID") )
What is the average and maximum number of total passengers for train stations in London or Glasgow?
SELECT avg(total_passengers) , max(total_passengers) FROM station WHERE LOCATION = 'London' OR LOCATION = 'Glasgow'
1
train_station
CREATE TABLE "station" ( "Station_ID" int, "Name" text, "Annual_entry_exit" real, "Annual_interchanges" real, "Total_Passengers" real, "Location" text, "Main_Services" text, "Number_of_Platforms" int, PRIMARY KEY ("Station_ID") ); CREATE TABLE "train" ( "Train_ID" int, "Name" text, "Time" text, "Service" text, PRIMARY KEY ("Train_ID") ); CREATE TABLE "train_station" ( "Train_ID" int, "Station_ID" int, PRIMARY KEY ("Train_ID","Station_ID"), FOREIGN KEY ("Train_ID") REFERENCES "train"("Train_ID"), FOREIGN KEY ("Station_ID") REFERENCES "station"("Station_ID") )
Show all locations and the total number of platforms and passengers for all train stations in each location.
SELECT LOCATION , sum(number_of_platforms) , sum(total_passengers) FROM station GROUP BY LOCATION
1
train_station
CREATE TABLE "station" ( "Station_ID" int, "Name" text, "Annual_entry_exit" real, "Annual_interchanges" real, "Total_Passengers" real, "Location" text, "Main_Services" text, "Number_of_Platforms" int, PRIMARY KEY ("Station_ID") ); CREATE TABLE "train" ( "Train_ID" int, "Name" text, "Time" text, "Service" text, PRIMARY KEY ("Train_ID") ); CREATE TABLE "train_station" ( "Train_ID" int, "Station_ID" int, PRIMARY KEY ("Train_ID","Station_ID"), FOREIGN KEY ("Train_ID") REFERENCES "train"("Train_ID"), FOREIGN KEY ("Station_ID") REFERENCES "station"("Station_ID") )
Show all locations that have train stations with at least 15 platforms and train stations with more than 25 total passengers.
SELECT DISTINCT LOCATION FROM station WHERE number_of_platforms >= 15 AND total_passengers > 25
1
train_station
CREATE TABLE "station" ( "Station_ID" int, "Name" text, "Annual_entry_exit" real, "Annual_interchanges" real, "Total_Passengers" real, "Location" text, "Main_Services" text, "Number_of_Platforms" int, PRIMARY KEY ("Station_ID") ); CREATE TABLE "train" ( "Train_ID" int, "Name" text, "Time" text, "Service" text, PRIMARY KEY ("Train_ID") ); CREATE TABLE "train_station" ( "Train_ID" int, "Station_ID" int, PRIMARY KEY ("Train_ID","Station_ID"), FOREIGN KEY ("Train_ID") REFERENCES "train"("Train_ID"), FOREIGN KEY ("Station_ID") REFERENCES "station"("Station_ID") )
Show all locations which don't have a train station with at least 15 platforms.
SELECT LOCATION FROM station EXCEPT SELECT LOCATION FROM station WHERE number_of_platforms >= 15
1
train_station
CREATE TABLE "station" ( "Station_ID" int, "Name" text, "Annual_entry_exit" real, "Annual_interchanges" real, "Total_Passengers" real, "Location" text, "Main_Services" text, "Number_of_Platforms" int, PRIMARY KEY ("Station_ID") ); CREATE TABLE "train" ( "Train_ID" int, "Name" text, "Time" text, "Service" text, PRIMARY KEY ("Train_ID") ); CREATE TABLE "train_station" ( "Train_ID" int, "Station_ID" int, PRIMARY KEY ("Train_ID","Station_ID"), FOREIGN KEY ("Train_ID") REFERENCES "train"("Train_ID"), FOREIGN KEY ("Station_ID") REFERENCES "station"("Station_ID") )
Show the location with most number of train stations.
SELECT LOCATION FROM station GROUP BY LOCATION ORDER BY count(*) DESC LIMIT 1
1
train_station
CREATE TABLE "station" ( "Station_ID" int, "Name" text, "Annual_entry_exit" real, "Annual_interchanges" real, "Total_Passengers" real, "Location" text, "Main_Services" text, "Number_of_Platforms" int, PRIMARY KEY ("Station_ID") ); CREATE TABLE "train" ( "Train_ID" int, "Name" text, "Time" text, "Service" text, PRIMARY KEY ("Train_ID") ); CREATE TABLE "train_station" ( "Train_ID" int, "Station_ID" int, PRIMARY KEY ("Train_ID","Station_ID"), FOREIGN KEY ("Train_ID") REFERENCES "train"("Train_ID"), FOREIGN KEY ("Station_ID") REFERENCES "station"("Station_ID") )
Show the name, time, and service for all trains.
SELECT name , TIME , service FROM train
1
train_station
CREATE TABLE "station" ( "Station_ID" int, "Name" text, "Annual_entry_exit" real, "Annual_interchanges" real, "Total_Passengers" real, "Location" text, "Main_Services" text, "Number_of_Platforms" int, PRIMARY KEY ("Station_ID") ); CREATE TABLE "train" ( "Train_ID" int, "Name" text, "Time" text, "Service" text, PRIMARY KEY ("Train_ID") ); CREATE TABLE "train_station" ( "Train_ID" int, "Station_ID" int, PRIMARY KEY ("Train_ID","Station_ID"), FOREIGN KEY ("Train_ID") REFERENCES "train"("Train_ID"), FOREIGN KEY ("Station_ID") REFERENCES "station"("Station_ID") )
Show the number of trains
SELECT count(*) FROM train
1
train_station
CREATE TABLE "station" ( "Station_ID" int, "Name" text, "Annual_entry_exit" real, "Annual_interchanges" real, "Total_Passengers" real, "Location" text, "Main_Services" text, "Number_of_Platforms" int, PRIMARY KEY ("Station_ID") ); CREATE TABLE "train" ( "Train_ID" int, "Name" text, "Time" text, "Service" text, PRIMARY KEY ("Train_ID") ); CREATE TABLE "train_station" ( "Train_ID" int, "Station_ID" int, PRIMARY KEY ("Train_ID","Station_ID"), FOREIGN KEY ("Train_ID") REFERENCES "train"("Train_ID"), FOREIGN KEY ("Station_ID") REFERENCES "station"("Station_ID") )
Show the name and service for all trains in order by time.
SELECT name , service FROM train ORDER BY TIME
1
train_station
CREATE TABLE "station" ( "Station_ID" int, "Name" text, "Annual_entry_exit" real, "Annual_interchanges" real, "Total_Passengers" real, "Location" text, "Main_Services" text, "Number_of_Platforms" int, PRIMARY KEY ("Station_ID") ); CREATE TABLE "train" ( "Train_ID" int, "Name" text, "Time" text, "Service" text, PRIMARY KEY ("Train_ID") ); CREATE TABLE "train_station" ( "Train_ID" int, "Station_ID" int, PRIMARY KEY ("Train_ID","Station_ID"), FOREIGN KEY ("Train_ID") REFERENCES "train"("Train_ID"), FOREIGN KEY ("Station_ID") REFERENCES "station"("Station_ID") )
Show the station name and number of trains in each station.
SELECT T2.name , count(*) FROM train_station AS T1 JOIN station AS T2 ON T1.station_id = T2.station_id GROUP BY T1.station_id
1
train_station
CREATE TABLE "station" ( "Station_ID" int, "Name" text, "Annual_entry_exit" real, "Annual_interchanges" real, "Total_Passengers" real, "Location" text, "Main_Services" text, "Number_of_Platforms" int, PRIMARY KEY ("Station_ID") ); CREATE TABLE "train" ( "Train_ID" int, "Name" text, "Time" text, "Service" text, PRIMARY KEY ("Train_ID") ); CREATE TABLE "train_station" ( "Train_ID" int, "Station_ID" int, PRIMARY KEY ("Train_ID","Station_ID"), FOREIGN KEY ("Train_ID") REFERENCES "train"("Train_ID"), FOREIGN KEY ("Station_ID") REFERENCES "station"("Station_ID") )
show the train name and station name for each train.
SELECT T2.name , T3.name FROM train_station AS T1 JOIN station AS T2 ON T1.station_id = T2.station_id JOIN train AS T3 ON T3.train_id = T1.train_id
1
train_station
CREATE TABLE "station" ( "Station_ID" int, "Name" text, "Annual_entry_exit" real, "Annual_interchanges" real, "Total_Passengers" real, "Location" text, "Main_Services" text, "Number_of_Platforms" int, PRIMARY KEY ("Station_ID") ); CREATE TABLE "train" ( "Train_ID" int, "Name" text, "Time" text, "Service" text, PRIMARY KEY ("Train_ID") ); CREATE TABLE "train_station" ( "Train_ID" int, "Station_ID" int, PRIMARY KEY ("Train_ID","Station_ID"), FOREIGN KEY ("Train_ID") REFERENCES "train"("Train_ID"), FOREIGN KEY ("Station_ID") REFERENCES "station"("Station_ID") )
Show all train names and times in stations in London in descending order by train time.
SELECT T3.name , T3.time FROM train_station AS T1 JOIN station AS T2 ON T1.station_id = T2.station_id JOIN train AS T3 ON T3.train_id = T1.train_id WHERE T2.location = 'London' ORDER BY T3.time DESC
1
train_station
CREATE TABLE "station" ( "Station_ID" int, "Name" text, "Annual_entry_exit" real, "Annual_interchanges" real, "Total_Passengers" real, "Location" text, "Main_Services" text, "Number_of_Platforms" int, PRIMARY KEY ("Station_ID") ); CREATE TABLE "train" ( "Train_ID" int, "Name" text, "Time" text, "Service" text, PRIMARY KEY ("Train_ID") ); CREATE TABLE "train_station" ( "Train_ID" int, "Station_ID" int, PRIMARY KEY ("Train_ID","Station_ID"), FOREIGN KEY ("Train_ID") REFERENCES "train"("Train_ID"), FOREIGN KEY ("Station_ID") REFERENCES "station"("Station_ID") )
Show the station name with greatest number of trains.
SELECT T2.name FROM train_station AS T1 JOIN station AS T2 ON T1.station_id = T2.station_id GROUP BY T1.station_id ORDER BY count(*) DESC LIMIT 1
1
train_station
CREATE TABLE "station" ( "Station_ID" int, "Name" text, "Annual_entry_exit" real, "Annual_interchanges" real, "Total_Passengers" real, "Location" text, "Main_Services" text, "Number_of_Platforms" int, PRIMARY KEY ("Station_ID") ); CREATE TABLE "train" ( "Train_ID" int, "Name" text, "Time" text, "Service" text, PRIMARY KEY ("Train_ID") ); CREATE TABLE "train_station" ( "Train_ID" int, "Station_ID" int, PRIMARY KEY ("Train_ID","Station_ID"), FOREIGN KEY ("Train_ID") REFERENCES "train"("Train_ID"), FOREIGN KEY ("Station_ID") REFERENCES "station"("Station_ID") )
Show the station name with at least two trains.
SELECT T2.name FROM train_station AS T1 JOIN station AS T2 ON T1.station_id = T2.station_id GROUP BY T1.station_id HAVING count(*) >= 2
1
train_station
CREATE TABLE "station" ( "Station_ID" int, "Name" text, "Annual_entry_exit" real, "Annual_interchanges" real, "Total_Passengers" real, "Location" text, "Main_Services" text, "Number_of_Platforms" int, PRIMARY KEY ("Station_ID") ); CREATE TABLE "train" ( "Train_ID" int, "Name" text, "Time" text, "Service" text, PRIMARY KEY ("Train_ID") ); CREATE TABLE "train_station" ( "Train_ID" int, "Station_ID" int, PRIMARY KEY ("Train_ID","Station_ID"), FOREIGN KEY ("Train_ID") REFERENCES "train"("Train_ID"), FOREIGN KEY ("Station_ID") REFERENCES "station"("Station_ID") )
Show all locations with only 1 station.
SELECT LOCATION FROM station GROUP BY LOCATION HAVING count(*) = 1
1
train_station
CREATE TABLE "station" ( "Station_ID" int, "Name" text, "Annual_entry_exit" real, "Annual_interchanges" real, "Total_Passengers" real, "Location" text, "Main_Services" text, "Number_of_Platforms" int, PRIMARY KEY ("Station_ID") ); CREATE TABLE "train" ( "Train_ID" int, "Name" text, "Time" text, "Service" text, PRIMARY KEY ("Train_ID") ); CREATE TABLE "train_station" ( "Train_ID" int, "Station_ID" int, PRIMARY KEY ("Train_ID","Station_ID"), FOREIGN KEY ("Train_ID") REFERENCES "train"("Train_ID"), FOREIGN KEY ("Station_ID") REFERENCES "station"("Station_ID") )
Show station names without any trains.
SELECT name FROM station WHERE station_id NOT IN (SELECT station_id FROM train_station)
1
train_station
CREATE TABLE "station" ( "Station_ID" int, "Name" text, "Annual_entry_exit" real, "Annual_interchanges" real, "Total_Passengers" real, "Location" text, "Main_Services" text, "Number_of_Platforms" int, PRIMARY KEY ("Station_ID") ); CREATE TABLE "train" ( "Train_ID" int, "Name" text, "Time" text, "Service" text, PRIMARY KEY ("Train_ID") ); CREATE TABLE "train_station" ( "Train_ID" int, "Station_ID" int, PRIMARY KEY ("Train_ID","Station_ID"), FOREIGN KEY ("Train_ID") REFERENCES "train"("Train_ID"), FOREIGN KEY ("Station_ID") REFERENCES "station"("Station_ID") )
What are the names of the stations which serve both "Ananthapuri Express" and "Guruvayur Express" trains?
SELECT T2.name FROM train_station AS T1 JOIN station AS T2 ON T1.station_id = T2.station_id JOIN train AS T3 ON T3.train_id = T1.train_id WHERE T3.Name = "Ananthapuri Express" INTERSECT SELECT T2.name FROM train_station AS T1 JOIN station AS T2 ON T1.station_id = T2.station_id JOIN train AS T3 ON T3.train_id = T1.train_id WHERE T3.Name = "Guruvayur Express"
1
train_station
CREATE TABLE "station" ( "Station_ID" int, "Name" text, "Annual_entry_exit" real, "Annual_interchanges" real, "Total_Passengers" real, "Location" text, "Main_Services" text, "Number_of_Platforms" int, PRIMARY KEY ("Station_ID") ); CREATE TABLE "train" ( "Train_ID" int, "Name" text, "Time" text, "Service" text, PRIMARY KEY ("Train_ID") ); CREATE TABLE "train_station" ( "Train_ID" int, "Station_ID" int, PRIMARY KEY ("Train_ID","Station_ID"), FOREIGN KEY ("Train_ID") REFERENCES "train"("Train_ID"), FOREIGN KEY ("Station_ID") REFERENCES "station"("Station_ID") )
Find the names of the trains that do not pass any station located in London.
SELECT T2.name FROM train_station AS T1 JOIN train AS T2 ON T1.train_id = T2.train_id WHERE T1.station_id NOT IN (SELECT T4.station_id FROM train_station AS T3 JOIN station AS T4 ON T3.station_id = T4.station_id WHERE t4.location = "London")
1
train_station
CREATE TABLE "station" ( "Station_ID" int, "Name" text, "Annual_entry_exit" real, "Annual_interchanges" real, "Total_Passengers" real, "Location" text, "Main_Services" text, "Number_of_Platforms" int, PRIMARY KEY ("Station_ID") ); CREATE TABLE "train" ( "Train_ID" int, "Name" text, "Time" text, "Service" text, PRIMARY KEY ("Train_ID") ); CREATE TABLE "train_station" ( "Train_ID" int, "Station_ID" int, PRIMARY KEY ("Train_ID","Station_ID"), FOREIGN KEY ("Train_ID") REFERENCES "train"("Train_ID"), FOREIGN KEY ("Station_ID") REFERENCES "station"("Station_ID") )
List the names and locations of all stations ordered by their yearly entry exit and interchange amounts.
SELECT name , LOCATION FROM station ORDER BY Annual_entry_exit , Annual_interchanges
1
driving_school
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_address_id` INTEGER NOT NULL, `nickname` VARCHAR(80), `first_name` VARCHAR(80), `middle_name` VARCHAR(80), `last_name` VARCHAR(80), `date_of_birth` DATETIME, `date_joined_staff` DATETIME, `date_left_staff` DATETIME, FOREIGN KEY (`staff_address_id` ) REFERENCES `Addresses`(`address_id` ) ); CREATE TABLE `Vehicles` ( `vehicle_id` INTEGER PRIMARY KEY, `vehicle_details` VARCHAR(255) ); CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `customer_address_id` INTEGER NOT NULL, `customer_status_code` VARCHAR(15) NOT NULL, `date_became_customer` DATETIME, `date_of_birth` DATETIME, `first_name` VARCHAR(80), `last_name` VARCHAR(80), `amount_outstanding` DOUBLE NULL, `email_address` VARCHAR(250), `phone_number` VARCHAR(255), `cell_mobile_phone_number` VARCHAR(255), FOREIGN KEY (`customer_address_id` ) REFERENCES `Addresses`(`address_id` ) ); CREATE TABLE `Customer_Payments` ( `customer_id` INTEGER NOT NULL, `datetime_payment` DATETIME NOT NULL, `payment_method_code` VARCHAR(10) NOT NULL, `amount_payment` DOUBLE NULL, PRIMARY KEY (`customer_id`,`datetime_payment`), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Lessons` ( `lesson_id` INTEGER PRIMARY KEY, `customer_id` INTEGER NOT NULL, `lesson_status_code` VARCHAR(15) NOT NULL, `staff_id` INTEGER, `vehicle_id` INTEGER NOT NULL, `lesson_date` DATETIME, `lesson_time` VARCHAR(10), `price` DOUBLE NULL, FOREIGN KEY (`vehicle_id` ) REFERENCES `Vehicles`(`vehicle_id` ), FOREIGN KEY (`staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) )
List all vehicle id
SELECT vehicle_id FROM Vehicles;
1
driving_school
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_address_id` INTEGER NOT NULL, `nickname` VARCHAR(80), `first_name` VARCHAR(80), `middle_name` VARCHAR(80), `last_name` VARCHAR(80), `date_of_birth` DATETIME, `date_joined_staff` DATETIME, `date_left_staff` DATETIME, FOREIGN KEY (`staff_address_id` ) REFERENCES `Addresses`(`address_id` ) ); CREATE TABLE `Vehicles` ( `vehicle_id` INTEGER PRIMARY KEY, `vehicle_details` VARCHAR(255) ); CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `customer_address_id` INTEGER NOT NULL, `customer_status_code` VARCHAR(15) NOT NULL, `date_became_customer` DATETIME, `date_of_birth` DATETIME, `first_name` VARCHAR(80), `last_name` VARCHAR(80), `amount_outstanding` DOUBLE NULL, `email_address` VARCHAR(250), `phone_number` VARCHAR(255), `cell_mobile_phone_number` VARCHAR(255), FOREIGN KEY (`customer_address_id` ) REFERENCES `Addresses`(`address_id` ) ); CREATE TABLE `Customer_Payments` ( `customer_id` INTEGER NOT NULL, `datetime_payment` DATETIME NOT NULL, `payment_method_code` VARCHAR(10) NOT NULL, `amount_payment` DOUBLE NULL, PRIMARY KEY (`customer_id`,`datetime_payment`), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Lessons` ( `lesson_id` INTEGER PRIMARY KEY, `customer_id` INTEGER NOT NULL, `lesson_status_code` VARCHAR(15) NOT NULL, `staff_id` INTEGER, `vehicle_id` INTEGER NOT NULL, `lesson_date` DATETIME, `lesson_time` VARCHAR(10), `price` DOUBLE NULL, FOREIGN KEY (`vehicle_id` ) REFERENCES `Vehicles`(`vehicle_id` ), FOREIGN KEY (`staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) )
What are the ids of all vehicles?
SELECT vehicle_id FROM Vehicles;
1
driving_school
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_address_id` INTEGER NOT NULL, `nickname` VARCHAR(80), `first_name` VARCHAR(80), `middle_name` VARCHAR(80), `last_name` VARCHAR(80), `date_of_birth` DATETIME, `date_joined_staff` DATETIME, `date_left_staff` DATETIME, FOREIGN KEY (`staff_address_id` ) REFERENCES `Addresses`(`address_id` ) ); CREATE TABLE `Vehicles` ( `vehicle_id` INTEGER PRIMARY KEY, `vehicle_details` VARCHAR(255) ); CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `customer_address_id` INTEGER NOT NULL, `customer_status_code` VARCHAR(15) NOT NULL, `date_became_customer` DATETIME, `date_of_birth` DATETIME, `first_name` VARCHAR(80), `last_name` VARCHAR(80), `amount_outstanding` DOUBLE NULL, `email_address` VARCHAR(250), `phone_number` VARCHAR(255), `cell_mobile_phone_number` VARCHAR(255), FOREIGN KEY (`customer_address_id` ) REFERENCES `Addresses`(`address_id` ) ); CREATE TABLE `Customer_Payments` ( `customer_id` INTEGER NOT NULL, `datetime_payment` DATETIME NOT NULL, `payment_method_code` VARCHAR(10) NOT NULL, `amount_payment` DOUBLE NULL, PRIMARY KEY (`customer_id`,`datetime_payment`), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Lessons` ( `lesson_id` INTEGER PRIMARY KEY, `customer_id` INTEGER NOT NULL, `lesson_status_code` VARCHAR(15) NOT NULL, `staff_id` INTEGER, `vehicle_id` INTEGER NOT NULL, `lesson_date` DATETIME, `lesson_time` VARCHAR(10), `price` DOUBLE NULL, FOREIGN KEY (`vehicle_id` ) REFERENCES `Vehicles`(`vehicle_id` ), FOREIGN KEY (`staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) )
How many vehicle in total?
SELECT count(*) FROM Vehicles;
1
driving_school
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_address_id` INTEGER NOT NULL, `nickname` VARCHAR(80), `first_name` VARCHAR(80), `middle_name` VARCHAR(80), `last_name` VARCHAR(80), `date_of_birth` DATETIME, `date_joined_staff` DATETIME, `date_left_staff` DATETIME, FOREIGN KEY (`staff_address_id` ) REFERENCES `Addresses`(`address_id` ) ); CREATE TABLE `Vehicles` ( `vehicle_id` INTEGER PRIMARY KEY, `vehicle_details` VARCHAR(255) ); CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `customer_address_id` INTEGER NOT NULL, `customer_status_code` VARCHAR(15) NOT NULL, `date_became_customer` DATETIME, `date_of_birth` DATETIME, `first_name` VARCHAR(80), `last_name` VARCHAR(80), `amount_outstanding` DOUBLE NULL, `email_address` VARCHAR(250), `phone_number` VARCHAR(255), `cell_mobile_phone_number` VARCHAR(255), FOREIGN KEY (`customer_address_id` ) REFERENCES `Addresses`(`address_id` ) ); CREATE TABLE `Customer_Payments` ( `customer_id` INTEGER NOT NULL, `datetime_payment` DATETIME NOT NULL, `payment_method_code` VARCHAR(10) NOT NULL, `amount_payment` DOUBLE NULL, PRIMARY KEY (`customer_id`,`datetime_payment`), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Lessons` ( `lesson_id` INTEGER PRIMARY KEY, `customer_id` INTEGER NOT NULL, `lesson_status_code` VARCHAR(15) NOT NULL, `staff_id` INTEGER, `vehicle_id` INTEGER NOT NULL, `lesson_date` DATETIME, `lesson_time` VARCHAR(10), `price` DOUBLE NULL, FOREIGN KEY (`vehicle_id` ) REFERENCES `Vehicles`(`vehicle_id` ), FOREIGN KEY (`staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) )
How many vehicles exist?
SELECT count(*) FROM Vehicles;
1
driving_school
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_address_id` INTEGER NOT NULL, `nickname` VARCHAR(80), `first_name` VARCHAR(80), `middle_name` VARCHAR(80), `last_name` VARCHAR(80), `date_of_birth` DATETIME, `date_joined_staff` DATETIME, `date_left_staff` DATETIME, FOREIGN KEY (`staff_address_id` ) REFERENCES `Addresses`(`address_id` ) ); CREATE TABLE `Vehicles` ( `vehicle_id` INTEGER PRIMARY KEY, `vehicle_details` VARCHAR(255) ); CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `customer_address_id` INTEGER NOT NULL, `customer_status_code` VARCHAR(15) NOT NULL, `date_became_customer` DATETIME, `date_of_birth` DATETIME, `first_name` VARCHAR(80), `last_name` VARCHAR(80), `amount_outstanding` DOUBLE NULL, `email_address` VARCHAR(250), `phone_number` VARCHAR(255), `cell_mobile_phone_number` VARCHAR(255), FOREIGN KEY (`customer_address_id` ) REFERENCES `Addresses`(`address_id` ) ); CREATE TABLE `Customer_Payments` ( `customer_id` INTEGER NOT NULL, `datetime_payment` DATETIME NOT NULL, `payment_method_code` VARCHAR(10) NOT NULL, `amount_payment` DOUBLE NULL, PRIMARY KEY (`customer_id`,`datetime_payment`), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Lessons` ( `lesson_id` INTEGER PRIMARY KEY, `customer_id` INTEGER NOT NULL, `lesson_status_code` VARCHAR(15) NOT NULL, `staff_id` INTEGER, `vehicle_id` INTEGER NOT NULL, `lesson_date` DATETIME, `lesson_time` VARCHAR(10), `price` DOUBLE NULL, FOREIGN KEY (`vehicle_id` ) REFERENCES `Vehicles`(`vehicle_id` ), FOREIGN KEY (`staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) )
Show the detail of vehicle with id 1.
SELECT vehicle_details FROM Vehicles WHERE vehicle_id = 1;
1
driving_school
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_address_id` INTEGER NOT NULL, `nickname` VARCHAR(80), `first_name` VARCHAR(80), `middle_name` VARCHAR(80), `last_name` VARCHAR(80), `date_of_birth` DATETIME, `date_joined_staff` DATETIME, `date_left_staff` DATETIME, FOREIGN KEY (`staff_address_id` ) REFERENCES `Addresses`(`address_id` ) ); CREATE TABLE `Vehicles` ( `vehicle_id` INTEGER PRIMARY KEY, `vehicle_details` VARCHAR(255) ); CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `customer_address_id` INTEGER NOT NULL, `customer_status_code` VARCHAR(15) NOT NULL, `date_became_customer` DATETIME, `date_of_birth` DATETIME, `first_name` VARCHAR(80), `last_name` VARCHAR(80), `amount_outstanding` DOUBLE NULL, `email_address` VARCHAR(250), `phone_number` VARCHAR(255), `cell_mobile_phone_number` VARCHAR(255), FOREIGN KEY (`customer_address_id` ) REFERENCES `Addresses`(`address_id` ) ); CREATE TABLE `Customer_Payments` ( `customer_id` INTEGER NOT NULL, `datetime_payment` DATETIME NOT NULL, `payment_method_code` VARCHAR(10) NOT NULL, `amount_payment` DOUBLE NULL, PRIMARY KEY (`customer_id`,`datetime_payment`), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Lessons` ( `lesson_id` INTEGER PRIMARY KEY, `customer_id` INTEGER NOT NULL, `lesson_status_code` VARCHAR(15) NOT NULL, `staff_id` INTEGER, `vehicle_id` INTEGER NOT NULL, `lesson_date` DATETIME, `lesson_time` VARCHAR(10), `price` DOUBLE NULL, FOREIGN KEY (`vehicle_id` ) REFERENCES `Vehicles`(`vehicle_id` ), FOREIGN KEY (`staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) )
What are the details of the car with id 1?
SELECT vehicle_details FROM Vehicles WHERE vehicle_id = 1;
1
driving_school
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_address_id` INTEGER NOT NULL, `nickname` VARCHAR(80), `first_name` VARCHAR(80), `middle_name` VARCHAR(80), `last_name` VARCHAR(80), `date_of_birth` DATETIME, `date_joined_staff` DATETIME, `date_left_staff` DATETIME, FOREIGN KEY (`staff_address_id` ) REFERENCES `Addresses`(`address_id` ) ); CREATE TABLE `Vehicles` ( `vehicle_id` INTEGER PRIMARY KEY, `vehicle_details` VARCHAR(255) ); CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `customer_address_id` INTEGER NOT NULL, `customer_status_code` VARCHAR(15) NOT NULL, `date_became_customer` DATETIME, `date_of_birth` DATETIME, `first_name` VARCHAR(80), `last_name` VARCHAR(80), `amount_outstanding` DOUBLE NULL, `email_address` VARCHAR(250), `phone_number` VARCHAR(255), `cell_mobile_phone_number` VARCHAR(255), FOREIGN KEY (`customer_address_id` ) REFERENCES `Addresses`(`address_id` ) ); CREATE TABLE `Customer_Payments` ( `customer_id` INTEGER NOT NULL, `datetime_payment` DATETIME NOT NULL, `payment_method_code` VARCHAR(10) NOT NULL, `amount_payment` DOUBLE NULL, PRIMARY KEY (`customer_id`,`datetime_payment`), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Lessons` ( `lesson_id` INTEGER PRIMARY KEY, `customer_id` INTEGER NOT NULL, `lesson_status_code` VARCHAR(15) NOT NULL, `staff_id` INTEGER, `vehicle_id` INTEGER NOT NULL, `lesson_date` DATETIME, `lesson_time` VARCHAR(10), `price` DOUBLE NULL, FOREIGN KEY (`vehicle_id` ) REFERENCES `Vehicles`(`vehicle_id` ), FOREIGN KEY (`staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) )
List the first name middle name and last name of all staff.
SELECT first_name , middle_name , last_name FROM Staff;
1
driving_school
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_address_id` INTEGER NOT NULL, `nickname` VARCHAR(80), `first_name` VARCHAR(80), `middle_name` VARCHAR(80), `last_name` VARCHAR(80), `date_of_birth` DATETIME, `date_joined_staff` DATETIME, `date_left_staff` DATETIME, FOREIGN KEY (`staff_address_id` ) REFERENCES `Addresses`(`address_id` ) ); CREATE TABLE `Vehicles` ( `vehicle_id` INTEGER PRIMARY KEY, `vehicle_details` VARCHAR(255) ); CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `customer_address_id` INTEGER NOT NULL, `customer_status_code` VARCHAR(15) NOT NULL, `date_became_customer` DATETIME, `date_of_birth` DATETIME, `first_name` VARCHAR(80), `last_name` VARCHAR(80), `amount_outstanding` DOUBLE NULL, `email_address` VARCHAR(250), `phone_number` VARCHAR(255), `cell_mobile_phone_number` VARCHAR(255), FOREIGN KEY (`customer_address_id` ) REFERENCES `Addresses`(`address_id` ) ); CREATE TABLE `Customer_Payments` ( `customer_id` INTEGER NOT NULL, `datetime_payment` DATETIME NOT NULL, `payment_method_code` VARCHAR(10) NOT NULL, `amount_payment` DOUBLE NULL, PRIMARY KEY (`customer_id`,`datetime_payment`), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Lessons` ( `lesson_id` INTEGER PRIMARY KEY, `customer_id` INTEGER NOT NULL, `lesson_status_code` VARCHAR(15) NOT NULL, `staff_id` INTEGER, `vehicle_id` INTEGER NOT NULL, `lesson_date` DATETIME, `lesson_time` VARCHAR(10), `price` DOUBLE NULL, FOREIGN KEY (`vehicle_id` ) REFERENCES `Vehicles`(`vehicle_id` ), FOREIGN KEY (`staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) )
What are the first, middle, and last names of all staff?
SELECT first_name , middle_name , last_name FROM Staff;
1
driving_school
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_address_id` INTEGER NOT NULL, `nickname` VARCHAR(80), `first_name` VARCHAR(80), `middle_name` VARCHAR(80), `last_name` VARCHAR(80), `date_of_birth` DATETIME, `date_joined_staff` DATETIME, `date_left_staff` DATETIME, FOREIGN KEY (`staff_address_id` ) REFERENCES `Addresses`(`address_id` ) ); CREATE TABLE `Vehicles` ( `vehicle_id` INTEGER PRIMARY KEY, `vehicle_details` VARCHAR(255) ); CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `customer_address_id` INTEGER NOT NULL, `customer_status_code` VARCHAR(15) NOT NULL, `date_became_customer` DATETIME, `date_of_birth` DATETIME, `first_name` VARCHAR(80), `last_name` VARCHAR(80), `amount_outstanding` DOUBLE NULL, `email_address` VARCHAR(250), `phone_number` VARCHAR(255), `cell_mobile_phone_number` VARCHAR(255), FOREIGN KEY (`customer_address_id` ) REFERENCES `Addresses`(`address_id` ) ); CREATE TABLE `Customer_Payments` ( `customer_id` INTEGER NOT NULL, `datetime_payment` DATETIME NOT NULL, `payment_method_code` VARCHAR(10) NOT NULL, `amount_payment` DOUBLE NULL, PRIMARY KEY (`customer_id`,`datetime_payment`), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Lessons` ( `lesson_id` INTEGER PRIMARY KEY, `customer_id` INTEGER NOT NULL, `lesson_status_code` VARCHAR(15) NOT NULL, `staff_id` INTEGER, `vehicle_id` INTEGER NOT NULL, `lesson_date` DATETIME, `lesson_time` VARCHAR(10), `price` DOUBLE NULL, FOREIGN KEY (`vehicle_id` ) REFERENCES `Vehicles`(`vehicle_id` ), FOREIGN KEY (`staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) )
What is the birthday of the staff member with first name as Janessa and last name as Sawayn?
SELECT date_of_birth FROM Staff WHERE first_name = "Janessa" AND last_name = "Sawayn";
1
driving_school
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_address_id` INTEGER NOT NULL, `nickname` VARCHAR(80), `first_name` VARCHAR(80), `middle_name` VARCHAR(80), `last_name` VARCHAR(80), `date_of_birth` DATETIME, `date_joined_staff` DATETIME, `date_left_staff` DATETIME, FOREIGN KEY (`staff_address_id` ) REFERENCES `Addresses`(`address_id` ) ); CREATE TABLE `Vehicles` ( `vehicle_id` INTEGER PRIMARY KEY, `vehicle_details` VARCHAR(255) ); CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `customer_address_id` INTEGER NOT NULL, `customer_status_code` VARCHAR(15) NOT NULL, `date_became_customer` DATETIME, `date_of_birth` DATETIME, `first_name` VARCHAR(80), `last_name` VARCHAR(80), `amount_outstanding` DOUBLE NULL, `email_address` VARCHAR(250), `phone_number` VARCHAR(255), `cell_mobile_phone_number` VARCHAR(255), FOREIGN KEY (`customer_address_id` ) REFERENCES `Addresses`(`address_id` ) ); CREATE TABLE `Customer_Payments` ( `customer_id` INTEGER NOT NULL, `datetime_payment` DATETIME NOT NULL, `payment_method_code` VARCHAR(10) NOT NULL, `amount_payment` DOUBLE NULL, PRIMARY KEY (`customer_id`,`datetime_payment`), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Lessons` ( `lesson_id` INTEGER PRIMARY KEY, `customer_id` INTEGER NOT NULL, `lesson_status_code` VARCHAR(15) NOT NULL, `staff_id` INTEGER, `vehicle_id` INTEGER NOT NULL, `lesson_date` DATETIME, `lesson_time` VARCHAR(10), `price` DOUBLE NULL, FOREIGN KEY (`vehicle_id` ) REFERENCES `Vehicles`(`vehicle_id` ), FOREIGN KEY (`staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) )
What is the date of birth for the staff member named Janessa Sawayn?
SELECT date_of_birth FROM Staff WHERE first_name = "Janessa" AND last_name = "Sawayn";
1
driving_school
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_address_id` INTEGER NOT NULL, `nickname` VARCHAR(80), `first_name` VARCHAR(80), `middle_name` VARCHAR(80), `last_name` VARCHAR(80), `date_of_birth` DATETIME, `date_joined_staff` DATETIME, `date_left_staff` DATETIME, FOREIGN KEY (`staff_address_id` ) REFERENCES `Addresses`(`address_id` ) ); CREATE TABLE `Vehicles` ( `vehicle_id` INTEGER PRIMARY KEY, `vehicle_details` VARCHAR(255) ); CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `customer_address_id` INTEGER NOT NULL, `customer_status_code` VARCHAR(15) NOT NULL, `date_became_customer` DATETIME, `date_of_birth` DATETIME, `first_name` VARCHAR(80), `last_name` VARCHAR(80), `amount_outstanding` DOUBLE NULL, `email_address` VARCHAR(250), `phone_number` VARCHAR(255), `cell_mobile_phone_number` VARCHAR(255), FOREIGN KEY (`customer_address_id` ) REFERENCES `Addresses`(`address_id` ) ); CREATE TABLE `Customer_Payments` ( `customer_id` INTEGER NOT NULL, `datetime_payment` DATETIME NOT NULL, `payment_method_code` VARCHAR(10) NOT NULL, `amount_payment` DOUBLE NULL, PRIMARY KEY (`customer_id`,`datetime_payment`), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Lessons` ( `lesson_id` INTEGER PRIMARY KEY, `customer_id` INTEGER NOT NULL, `lesson_status_code` VARCHAR(15) NOT NULL, `staff_id` INTEGER, `vehicle_id` INTEGER NOT NULL, `lesson_date` DATETIME, `lesson_time` VARCHAR(10), `price` DOUBLE NULL, FOREIGN KEY (`vehicle_id` ) REFERENCES `Vehicles`(`vehicle_id` ), FOREIGN KEY (`staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) )
When did the staff member with first name as Janessa and last name as Sawayn join the company?
SELECT date_joined_staff FROM Staff WHERE first_name = "Janessa" AND last_name = "Sawayn";
1
driving_school
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_address_id` INTEGER NOT NULL, `nickname` VARCHAR(80), `first_name` VARCHAR(80), `middle_name` VARCHAR(80), `last_name` VARCHAR(80), `date_of_birth` DATETIME, `date_joined_staff` DATETIME, `date_left_staff` DATETIME, FOREIGN KEY (`staff_address_id` ) REFERENCES `Addresses`(`address_id` ) ); CREATE TABLE `Vehicles` ( `vehicle_id` INTEGER PRIMARY KEY, `vehicle_details` VARCHAR(255) ); CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `customer_address_id` INTEGER NOT NULL, `customer_status_code` VARCHAR(15) NOT NULL, `date_became_customer` DATETIME, `date_of_birth` DATETIME, `first_name` VARCHAR(80), `last_name` VARCHAR(80), `amount_outstanding` DOUBLE NULL, `email_address` VARCHAR(250), `phone_number` VARCHAR(255), `cell_mobile_phone_number` VARCHAR(255), FOREIGN KEY (`customer_address_id` ) REFERENCES `Addresses`(`address_id` ) ); CREATE TABLE `Customer_Payments` ( `customer_id` INTEGER NOT NULL, `datetime_payment` DATETIME NOT NULL, `payment_method_code` VARCHAR(10) NOT NULL, `amount_payment` DOUBLE NULL, PRIMARY KEY (`customer_id`,`datetime_payment`), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Lessons` ( `lesson_id` INTEGER PRIMARY KEY, `customer_id` INTEGER NOT NULL, `lesson_status_code` VARCHAR(15) NOT NULL, `staff_id` INTEGER, `vehicle_id` INTEGER NOT NULL, `lesson_date` DATETIME, `lesson_time` VARCHAR(10), `price` DOUBLE NULL, FOREIGN KEY (`vehicle_id` ) REFERENCES `Vehicles`(`vehicle_id` ), FOREIGN KEY (`staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) )
When did the staff member named Janessa Sawayn join the company?
SELECT date_joined_staff FROM Staff WHERE first_name = "Janessa" AND last_name = "Sawayn";
1
driving_school
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_address_id` INTEGER NOT NULL, `nickname` VARCHAR(80), `first_name` VARCHAR(80), `middle_name` VARCHAR(80), `last_name` VARCHAR(80), `date_of_birth` DATETIME, `date_joined_staff` DATETIME, `date_left_staff` DATETIME, FOREIGN KEY (`staff_address_id` ) REFERENCES `Addresses`(`address_id` ) ); CREATE TABLE `Vehicles` ( `vehicle_id` INTEGER PRIMARY KEY, `vehicle_details` VARCHAR(255) ); CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `customer_address_id` INTEGER NOT NULL, `customer_status_code` VARCHAR(15) NOT NULL, `date_became_customer` DATETIME, `date_of_birth` DATETIME, `first_name` VARCHAR(80), `last_name` VARCHAR(80), `amount_outstanding` DOUBLE NULL, `email_address` VARCHAR(250), `phone_number` VARCHAR(255), `cell_mobile_phone_number` VARCHAR(255), FOREIGN KEY (`customer_address_id` ) REFERENCES `Addresses`(`address_id` ) ); CREATE TABLE `Customer_Payments` ( `customer_id` INTEGER NOT NULL, `datetime_payment` DATETIME NOT NULL, `payment_method_code` VARCHAR(10) NOT NULL, `amount_payment` DOUBLE NULL, PRIMARY KEY (`customer_id`,`datetime_payment`), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Lessons` ( `lesson_id` INTEGER PRIMARY KEY, `customer_id` INTEGER NOT NULL, `lesson_status_code` VARCHAR(15) NOT NULL, `staff_id` INTEGER, `vehicle_id` INTEGER NOT NULL, `lesson_date` DATETIME, `lesson_time` VARCHAR(10), `price` DOUBLE NULL, FOREIGN KEY (`vehicle_id` ) REFERENCES `Vehicles`(`vehicle_id` ), FOREIGN KEY (`staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) )
When did the staff member with first name as Janessa and last name as Sawayn leave the company?
SELECT date_left_staff FROM Staff WHERE first_name = "Janessa" AND last_name = "Sawayn";
1
driving_school
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_address_id` INTEGER NOT NULL, `nickname` VARCHAR(80), `first_name` VARCHAR(80), `middle_name` VARCHAR(80), `last_name` VARCHAR(80), `date_of_birth` DATETIME, `date_joined_staff` DATETIME, `date_left_staff` DATETIME, FOREIGN KEY (`staff_address_id` ) REFERENCES `Addresses`(`address_id` ) ); CREATE TABLE `Vehicles` ( `vehicle_id` INTEGER PRIMARY KEY, `vehicle_details` VARCHAR(255) ); CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `customer_address_id` INTEGER NOT NULL, `customer_status_code` VARCHAR(15) NOT NULL, `date_became_customer` DATETIME, `date_of_birth` DATETIME, `first_name` VARCHAR(80), `last_name` VARCHAR(80), `amount_outstanding` DOUBLE NULL, `email_address` VARCHAR(250), `phone_number` VARCHAR(255), `cell_mobile_phone_number` VARCHAR(255), FOREIGN KEY (`customer_address_id` ) REFERENCES `Addresses`(`address_id` ) ); CREATE TABLE `Customer_Payments` ( `customer_id` INTEGER NOT NULL, `datetime_payment` DATETIME NOT NULL, `payment_method_code` VARCHAR(10) NOT NULL, `amount_payment` DOUBLE NULL, PRIMARY KEY (`customer_id`,`datetime_payment`), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Lessons` ( `lesson_id` INTEGER PRIMARY KEY, `customer_id` INTEGER NOT NULL, `lesson_status_code` VARCHAR(15) NOT NULL, `staff_id` INTEGER, `vehicle_id` INTEGER NOT NULL, `lesson_date` DATETIME, `lesson_time` VARCHAR(10), `price` DOUBLE NULL, FOREIGN KEY (`vehicle_id` ) REFERENCES `Vehicles`(`vehicle_id` ), FOREIGN KEY (`staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) )
When did the staff member Janessa Sawayn leave the company?
SELECT date_left_staff FROM Staff WHERE first_name = "Janessa" AND last_name = "Sawayn";
1
driving_school
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_address_id` INTEGER NOT NULL, `nickname` VARCHAR(80), `first_name` VARCHAR(80), `middle_name` VARCHAR(80), `last_name` VARCHAR(80), `date_of_birth` DATETIME, `date_joined_staff` DATETIME, `date_left_staff` DATETIME, FOREIGN KEY (`staff_address_id` ) REFERENCES `Addresses`(`address_id` ) ); CREATE TABLE `Vehicles` ( `vehicle_id` INTEGER PRIMARY KEY, `vehicle_details` VARCHAR(255) ); CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `customer_address_id` INTEGER NOT NULL, `customer_status_code` VARCHAR(15) NOT NULL, `date_became_customer` DATETIME, `date_of_birth` DATETIME, `first_name` VARCHAR(80), `last_name` VARCHAR(80), `amount_outstanding` DOUBLE NULL, `email_address` VARCHAR(250), `phone_number` VARCHAR(255), `cell_mobile_phone_number` VARCHAR(255), FOREIGN KEY (`customer_address_id` ) REFERENCES `Addresses`(`address_id` ) ); CREATE TABLE `Customer_Payments` ( `customer_id` INTEGER NOT NULL, `datetime_payment` DATETIME NOT NULL, `payment_method_code` VARCHAR(10) NOT NULL, `amount_payment` DOUBLE NULL, PRIMARY KEY (`customer_id`,`datetime_payment`), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Lessons` ( `lesson_id` INTEGER PRIMARY KEY, `customer_id` INTEGER NOT NULL, `lesson_status_code` VARCHAR(15) NOT NULL, `staff_id` INTEGER, `vehicle_id` INTEGER NOT NULL, `lesson_date` DATETIME, `lesson_time` VARCHAR(10), `price` DOUBLE NULL, FOREIGN KEY (`vehicle_id` ) REFERENCES `Vehicles`(`vehicle_id` ), FOREIGN KEY (`staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) )
How many staff have the first name Ludie?
SELECT count(*) FROM Staff WHERE first_name = "Ludie";
1
driving_school
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_address_id` INTEGER NOT NULL, `nickname` VARCHAR(80), `first_name` VARCHAR(80), `middle_name` VARCHAR(80), `last_name` VARCHAR(80), `date_of_birth` DATETIME, `date_joined_staff` DATETIME, `date_left_staff` DATETIME, FOREIGN KEY (`staff_address_id` ) REFERENCES `Addresses`(`address_id` ) ); CREATE TABLE `Vehicles` ( `vehicle_id` INTEGER PRIMARY KEY, `vehicle_details` VARCHAR(255) ); CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `customer_address_id` INTEGER NOT NULL, `customer_status_code` VARCHAR(15) NOT NULL, `date_became_customer` DATETIME, `date_of_birth` DATETIME, `first_name` VARCHAR(80), `last_name` VARCHAR(80), `amount_outstanding` DOUBLE NULL, `email_address` VARCHAR(250), `phone_number` VARCHAR(255), `cell_mobile_phone_number` VARCHAR(255), FOREIGN KEY (`customer_address_id` ) REFERENCES `Addresses`(`address_id` ) ); CREATE TABLE `Customer_Payments` ( `customer_id` INTEGER NOT NULL, `datetime_payment` DATETIME NOT NULL, `payment_method_code` VARCHAR(10) NOT NULL, `amount_payment` DOUBLE NULL, PRIMARY KEY (`customer_id`,`datetime_payment`), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Lessons` ( `lesson_id` INTEGER PRIMARY KEY, `customer_id` INTEGER NOT NULL, `lesson_status_code` VARCHAR(15) NOT NULL, `staff_id` INTEGER, `vehicle_id` INTEGER NOT NULL, `lesson_date` DATETIME, `lesson_time` VARCHAR(10), `price` DOUBLE NULL, FOREIGN KEY (`vehicle_id` ) REFERENCES `Vehicles`(`vehicle_id` ), FOREIGN KEY (`staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) )
How many employees have a first name of Ludie?
SELECT count(*) FROM Staff WHERE first_name = "Ludie";
1
driving_school
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_address_id` INTEGER NOT NULL, `nickname` VARCHAR(80), `first_name` VARCHAR(80), `middle_name` VARCHAR(80), `last_name` VARCHAR(80), `date_of_birth` DATETIME, `date_joined_staff` DATETIME, `date_left_staff` DATETIME, FOREIGN KEY (`staff_address_id` ) REFERENCES `Addresses`(`address_id` ) ); CREATE TABLE `Vehicles` ( `vehicle_id` INTEGER PRIMARY KEY, `vehicle_details` VARCHAR(255) ); CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `customer_address_id` INTEGER NOT NULL, `customer_status_code` VARCHAR(15) NOT NULL, `date_became_customer` DATETIME, `date_of_birth` DATETIME, `first_name` VARCHAR(80), `last_name` VARCHAR(80), `amount_outstanding` DOUBLE NULL, `email_address` VARCHAR(250), `phone_number` VARCHAR(255), `cell_mobile_phone_number` VARCHAR(255), FOREIGN KEY (`customer_address_id` ) REFERENCES `Addresses`(`address_id` ) ); CREATE TABLE `Customer_Payments` ( `customer_id` INTEGER NOT NULL, `datetime_payment` DATETIME NOT NULL, `payment_method_code` VARCHAR(10) NOT NULL, `amount_payment` DOUBLE NULL, PRIMARY KEY (`customer_id`,`datetime_payment`), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Lessons` ( `lesson_id` INTEGER PRIMARY KEY, `customer_id` INTEGER NOT NULL, `lesson_status_code` VARCHAR(15) NOT NULL, `staff_id` INTEGER, `vehicle_id` INTEGER NOT NULL, `lesson_date` DATETIME, `lesson_time` VARCHAR(10), `price` DOUBLE NULL, FOREIGN KEY (`vehicle_id` ) REFERENCES `Vehicles`(`vehicle_id` ), FOREIGN KEY (`staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) )
What is the nickname of staff with first name as Janessa and last name as Sawayn?
SELECT nickname FROM Staff WHERE first_name = "Janessa" AND last_name = "Sawayn";
1
driving_school
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_address_id` INTEGER NOT NULL, `nickname` VARCHAR(80), `first_name` VARCHAR(80), `middle_name` VARCHAR(80), `last_name` VARCHAR(80), `date_of_birth` DATETIME, `date_joined_staff` DATETIME, `date_left_staff` DATETIME, FOREIGN KEY (`staff_address_id` ) REFERENCES `Addresses`(`address_id` ) ); CREATE TABLE `Vehicles` ( `vehicle_id` INTEGER PRIMARY KEY, `vehicle_details` VARCHAR(255) ); CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `customer_address_id` INTEGER NOT NULL, `customer_status_code` VARCHAR(15) NOT NULL, `date_became_customer` DATETIME, `date_of_birth` DATETIME, `first_name` VARCHAR(80), `last_name` VARCHAR(80), `amount_outstanding` DOUBLE NULL, `email_address` VARCHAR(250), `phone_number` VARCHAR(255), `cell_mobile_phone_number` VARCHAR(255), FOREIGN KEY (`customer_address_id` ) REFERENCES `Addresses`(`address_id` ) ); CREATE TABLE `Customer_Payments` ( `customer_id` INTEGER NOT NULL, `datetime_payment` DATETIME NOT NULL, `payment_method_code` VARCHAR(10) NOT NULL, `amount_payment` DOUBLE NULL, PRIMARY KEY (`customer_id`,`datetime_payment`), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Lessons` ( `lesson_id` INTEGER PRIMARY KEY, `customer_id` INTEGER NOT NULL, `lesson_status_code` VARCHAR(15) NOT NULL, `staff_id` INTEGER, `vehicle_id` INTEGER NOT NULL, `lesson_date` DATETIME, `lesson_time` VARCHAR(10), `price` DOUBLE NULL, FOREIGN KEY (`vehicle_id` ) REFERENCES `Vehicles`(`vehicle_id` ), FOREIGN KEY (`staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) )
What is the nickname of the employee named Janessa Sawayn?
SELECT nickname FROM Staff WHERE first_name = "Janessa" AND last_name = "Sawayn";
1
driving_school
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_address_id` INTEGER NOT NULL, `nickname` VARCHAR(80), `first_name` VARCHAR(80), `middle_name` VARCHAR(80), `last_name` VARCHAR(80), `date_of_birth` DATETIME, `date_joined_staff` DATETIME, `date_left_staff` DATETIME, FOREIGN KEY (`staff_address_id` ) REFERENCES `Addresses`(`address_id` ) ); CREATE TABLE `Vehicles` ( `vehicle_id` INTEGER PRIMARY KEY, `vehicle_details` VARCHAR(255) ); CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `customer_address_id` INTEGER NOT NULL, `customer_status_code` VARCHAR(15) NOT NULL, `date_became_customer` DATETIME, `date_of_birth` DATETIME, `first_name` VARCHAR(80), `last_name` VARCHAR(80), `amount_outstanding` DOUBLE NULL, `email_address` VARCHAR(250), `phone_number` VARCHAR(255), `cell_mobile_phone_number` VARCHAR(255), FOREIGN KEY (`customer_address_id` ) REFERENCES `Addresses`(`address_id` ) ); CREATE TABLE `Customer_Payments` ( `customer_id` INTEGER NOT NULL, `datetime_payment` DATETIME NOT NULL, `payment_method_code` VARCHAR(10) NOT NULL, `amount_payment` DOUBLE NULL, PRIMARY KEY (`customer_id`,`datetime_payment`), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Lessons` ( `lesson_id` INTEGER PRIMARY KEY, `customer_id` INTEGER NOT NULL, `lesson_status_code` VARCHAR(15) NOT NULL, `staff_id` INTEGER, `vehicle_id` INTEGER NOT NULL, `lesson_date` DATETIME, `lesson_time` VARCHAR(10), `price` DOUBLE NULL, FOREIGN KEY (`vehicle_id` ) REFERENCES `Vehicles`(`vehicle_id` ), FOREIGN KEY (`staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) )
How many staff in total?
SELECT count(*) FROM Staff;
1
driving_school
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_address_id` INTEGER NOT NULL, `nickname` VARCHAR(80), `first_name` VARCHAR(80), `middle_name` VARCHAR(80), `last_name` VARCHAR(80), `date_of_birth` DATETIME, `date_joined_staff` DATETIME, `date_left_staff` DATETIME, FOREIGN KEY (`staff_address_id` ) REFERENCES `Addresses`(`address_id` ) ); CREATE TABLE `Vehicles` ( `vehicle_id` INTEGER PRIMARY KEY, `vehicle_details` VARCHAR(255) ); CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `customer_address_id` INTEGER NOT NULL, `customer_status_code` VARCHAR(15) NOT NULL, `date_became_customer` DATETIME, `date_of_birth` DATETIME, `first_name` VARCHAR(80), `last_name` VARCHAR(80), `amount_outstanding` DOUBLE NULL, `email_address` VARCHAR(250), `phone_number` VARCHAR(255), `cell_mobile_phone_number` VARCHAR(255), FOREIGN KEY (`customer_address_id` ) REFERENCES `Addresses`(`address_id` ) ); CREATE TABLE `Customer_Payments` ( `customer_id` INTEGER NOT NULL, `datetime_payment` DATETIME NOT NULL, `payment_method_code` VARCHAR(10) NOT NULL, `amount_payment` DOUBLE NULL, PRIMARY KEY (`customer_id`,`datetime_payment`), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Lessons` ( `lesson_id` INTEGER PRIMARY KEY, `customer_id` INTEGER NOT NULL, `lesson_status_code` VARCHAR(15) NOT NULL, `staff_id` INTEGER, `vehicle_id` INTEGER NOT NULL, `lesson_date` DATETIME, `lesson_time` VARCHAR(10), `price` DOUBLE NULL, FOREIGN KEY (`vehicle_id` ) REFERENCES `Vehicles`(`vehicle_id` ), FOREIGN KEY (`staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) )
How many employees are there?
SELECT count(*) FROM Staff;
1
driving_school
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_address_id` INTEGER NOT NULL, `nickname` VARCHAR(80), `first_name` VARCHAR(80), `middle_name` VARCHAR(80), `last_name` VARCHAR(80), `date_of_birth` DATETIME, `date_joined_staff` DATETIME, `date_left_staff` DATETIME, FOREIGN KEY (`staff_address_id` ) REFERENCES `Addresses`(`address_id` ) ); CREATE TABLE `Vehicles` ( `vehicle_id` INTEGER PRIMARY KEY, `vehicle_details` VARCHAR(255) ); CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `customer_address_id` INTEGER NOT NULL, `customer_status_code` VARCHAR(15) NOT NULL, `date_became_customer` DATETIME, `date_of_birth` DATETIME, `first_name` VARCHAR(80), `last_name` VARCHAR(80), `amount_outstanding` DOUBLE NULL, `email_address` VARCHAR(250), `phone_number` VARCHAR(255), `cell_mobile_phone_number` VARCHAR(255), FOREIGN KEY (`customer_address_id` ) REFERENCES `Addresses`(`address_id` ) ); CREATE TABLE `Customer_Payments` ( `customer_id` INTEGER NOT NULL, `datetime_payment` DATETIME NOT NULL, `payment_method_code` VARCHAR(10) NOT NULL, `amount_payment` DOUBLE NULL, PRIMARY KEY (`customer_id`,`datetime_payment`), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Lessons` ( `lesson_id` INTEGER PRIMARY KEY, `customer_id` INTEGER NOT NULL, `lesson_status_code` VARCHAR(15) NOT NULL, `staff_id` INTEGER, `vehicle_id` INTEGER NOT NULL, `lesson_date` DATETIME, `lesson_time` VARCHAR(10), `price` DOUBLE NULL, FOREIGN KEY (`vehicle_id` ) REFERENCES `Vehicles`(`vehicle_id` ), FOREIGN KEY (`staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) )
Which city does staff with first name as Janessa and last name as Sawayn live?
SELECT T1.city FROM Addresses AS T1 JOIN Staff AS T2 ON T1.address_id = T2.staff_address_id WHERE T2.first_name = "Janessa" AND T2.last_name = "Sawayn";
1
driving_school
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_address_id` INTEGER NOT NULL, `nickname` VARCHAR(80), `first_name` VARCHAR(80), `middle_name` VARCHAR(80), `last_name` VARCHAR(80), `date_of_birth` DATETIME, `date_joined_staff` DATETIME, `date_left_staff` DATETIME, FOREIGN KEY (`staff_address_id` ) REFERENCES `Addresses`(`address_id` ) ); CREATE TABLE `Vehicles` ( `vehicle_id` INTEGER PRIMARY KEY, `vehicle_details` VARCHAR(255) ); CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `customer_address_id` INTEGER NOT NULL, `customer_status_code` VARCHAR(15) NOT NULL, `date_became_customer` DATETIME, `date_of_birth` DATETIME, `first_name` VARCHAR(80), `last_name` VARCHAR(80), `amount_outstanding` DOUBLE NULL, `email_address` VARCHAR(250), `phone_number` VARCHAR(255), `cell_mobile_phone_number` VARCHAR(255), FOREIGN KEY (`customer_address_id` ) REFERENCES `Addresses`(`address_id` ) ); CREATE TABLE `Customer_Payments` ( `customer_id` INTEGER NOT NULL, `datetime_payment` DATETIME NOT NULL, `payment_method_code` VARCHAR(10) NOT NULL, `amount_payment` DOUBLE NULL, PRIMARY KEY (`customer_id`,`datetime_payment`), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Lessons` ( `lesson_id` INTEGER PRIMARY KEY, `customer_id` INTEGER NOT NULL, `lesson_status_code` VARCHAR(15) NOT NULL, `staff_id` INTEGER, `vehicle_id` INTEGER NOT NULL, `lesson_date` DATETIME, `lesson_time` VARCHAR(10), `price` DOUBLE NULL, FOREIGN KEY (`vehicle_id` ) REFERENCES `Vehicles`(`vehicle_id` ), FOREIGN KEY (`staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) )
In what city does Janessa Sawayn live?
SELECT T1.city FROM Addresses AS T1 JOIN Staff AS T2 ON T1.address_id = T2.staff_address_id WHERE T2.first_name = "Janessa" AND T2.last_name = "Sawayn";
1
driving_school
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_address_id` INTEGER NOT NULL, `nickname` VARCHAR(80), `first_name` VARCHAR(80), `middle_name` VARCHAR(80), `last_name` VARCHAR(80), `date_of_birth` DATETIME, `date_joined_staff` DATETIME, `date_left_staff` DATETIME, FOREIGN KEY (`staff_address_id` ) REFERENCES `Addresses`(`address_id` ) ); CREATE TABLE `Vehicles` ( `vehicle_id` INTEGER PRIMARY KEY, `vehicle_details` VARCHAR(255) ); CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `customer_address_id` INTEGER NOT NULL, `customer_status_code` VARCHAR(15) NOT NULL, `date_became_customer` DATETIME, `date_of_birth` DATETIME, `first_name` VARCHAR(80), `last_name` VARCHAR(80), `amount_outstanding` DOUBLE NULL, `email_address` VARCHAR(250), `phone_number` VARCHAR(255), `cell_mobile_phone_number` VARCHAR(255), FOREIGN KEY (`customer_address_id` ) REFERENCES `Addresses`(`address_id` ) ); CREATE TABLE `Customer_Payments` ( `customer_id` INTEGER NOT NULL, `datetime_payment` DATETIME NOT NULL, `payment_method_code` VARCHAR(10) NOT NULL, `amount_payment` DOUBLE NULL, PRIMARY KEY (`customer_id`,`datetime_payment`), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Lessons` ( `lesson_id` INTEGER PRIMARY KEY, `customer_id` INTEGER NOT NULL, `lesson_status_code` VARCHAR(15) NOT NULL, `staff_id` INTEGER, `vehicle_id` INTEGER NOT NULL, `lesson_date` DATETIME, `lesson_time` VARCHAR(10), `price` DOUBLE NULL, FOREIGN KEY (`vehicle_id` ) REFERENCES `Vehicles`(`vehicle_id` ), FOREIGN KEY (`staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) )
Which country and state does staff with first name as Janessa and last name as Sawayn lived?
SELECT T1.country , T1.state_province_county FROM Addresses AS T1 JOIN Staff AS T2 ON T1.address_id = T2.staff_address_id WHERE T2.first_name = "Janessa" AND T2.last_name = "Sawayn";
1
driving_school
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_address_id` INTEGER NOT NULL, `nickname` VARCHAR(80), `first_name` VARCHAR(80), `middle_name` VARCHAR(80), `last_name` VARCHAR(80), `date_of_birth` DATETIME, `date_joined_staff` DATETIME, `date_left_staff` DATETIME, FOREIGN KEY (`staff_address_id` ) REFERENCES `Addresses`(`address_id` ) ); CREATE TABLE `Vehicles` ( `vehicle_id` INTEGER PRIMARY KEY, `vehicle_details` VARCHAR(255) ); CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `customer_address_id` INTEGER NOT NULL, `customer_status_code` VARCHAR(15) NOT NULL, `date_became_customer` DATETIME, `date_of_birth` DATETIME, `first_name` VARCHAR(80), `last_name` VARCHAR(80), `amount_outstanding` DOUBLE NULL, `email_address` VARCHAR(250), `phone_number` VARCHAR(255), `cell_mobile_phone_number` VARCHAR(255), FOREIGN KEY (`customer_address_id` ) REFERENCES `Addresses`(`address_id` ) ); CREATE TABLE `Customer_Payments` ( `customer_id` INTEGER NOT NULL, `datetime_payment` DATETIME NOT NULL, `payment_method_code` VARCHAR(10) NOT NULL, `amount_payment` DOUBLE NULL, PRIMARY KEY (`customer_id`,`datetime_payment`), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Lessons` ( `lesson_id` INTEGER PRIMARY KEY, `customer_id` INTEGER NOT NULL, `lesson_status_code` VARCHAR(15) NOT NULL, `staff_id` INTEGER, `vehicle_id` INTEGER NOT NULL, `lesson_date` DATETIME, `lesson_time` VARCHAR(10), `price` DOUBLE NULL, FOREIGN KEY (`vehicle_id` ) REFERENCES `Vehicles`(`vehicle_id` ), FOREIGN KEY (`staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) )
In which country and state does Janessa Sawayn live?
SELECT T1.country , T1.state_province_county FROM Addresses AS T1 JOIN Staff AS T2 ON T1.address_id = T2.staff_address_id WHERE T2.first_name = "Janessa" AND T2.last_name = "Sawayn";
1
driving_school
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_address_id` INTEGER NOT NULL, `nickname` VARCHAR(80), `first_name` VARCHAR(80), `middle_name` VARCHAR(80), `last_name` VARCHAR(80), `date_of_birth` DATETIME, `date_joined_staff` DATETIME, `date_left_staff` DATETIME, FOREIGN KEY (`staff_address_id` ) REFERENCES `Addresses`(`address_id` ) ); CREATE TABLE `Vehicles` ( `vehicle_id` INTEGER PRIMARY KEY, `vehicle_details` VARCHAR(255) ); CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `customer_address_id` INTEGER NOT NULL, `customer_status_code` VARCHAR(15) NOT NULL, `date_became_customer` DATETIME, `date_of_birth` DATETIME, `first_name` VARCHAR(80), `last_name` VARCHAR(80), `amount_outstanding` DOUBLE NULL, `email_address` VARCHAR(250), `phone_number` VARCHAR(255), `cell_mobile_phone_number` VARCHAR(255), FOREIGN KEY (`customer_address_id` ) REFERENCES `Addresses`(`address_id` ) ); CREATE TABLE `Customer_Payments` ( `customer_id` INTEGER NOT NULL, `datetime_payment` DATETIME NOT NULL, `payment_method_code` VARCHAR(10) NOT NULL, `amount_payment` DOUBLE NULL, PRIMARY KEY (`customer_id`,`datetime_payment`), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Lessons` ( `lesson_id` INTEGER PRIMARY KEY, `customer_id` INTEGER NOT NULL, `lesson_status_code` VARCHAR(15) NOT NULL, `staff_id` INTEGER, `vehicle_id` INTEGER NOT NULL, `lesson_date` DATETIME, `lesson_time` VARCHAR(10), `price` DOUBLE NULL, FOREIGN KEY (`vehicle_id` ) REFERENCES `Vehicles`(`vehicle_id` ), FOREIGN KEY (`staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) )
How long is the total lesson time took by customer with first name as Rylan and last name as Goodwin?
SELECT sum(T1.lesson_time) FROM Lessons AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id WHERE T2.first_name = "Rylan" AND T2.last_name = "Goodwin";
1
driving_school
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_address_id` INTEGER NOT NULL, `nickname` VARCHAR(80), `first_name` VARCHAR(80), `middle_name` VARCHAR(80), `last_name` VARCHAR(80), `date_of_birth` DATETIME, `date_joined_staff` DATETIME, `date_left_staff` DATETIME, FOREIGN KEY (`staff_address_id` ) REFERENCES `Addresses`(`address_id` ) ); CREATE TABLE `Vehicles` ( `vehicle_id` INTEGER PRIMARY KEY, `vehicle_details` VARCHAR(255) ); CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `customer_address_id` INTEGER NOT NULL, `customer_status_code` VARCHAR(15) NOT NULL, `date_became_customer` DATETIME, `date_of_birth` DATETIME, `first_name` VARCHAR(80), `last_name` VARCHAR(80), `amount_outstanding` DOUBLE NULL, `email_address` VARCHAR(250), `phone_number` VARCHAR(255), `cell_mobile_phone_number` VARCHAR(255), FOREIGN KEY (`customer_address_id` ) REFERENCES `Addresses`(`address_id` ) ); CREATE TABLE `Customer_Payments` ( `customer_id` INTEGER NOT NULL, `datetime_payment` DATETIME NOT NULL, `payment_method_code` VARCHAR(10) NOT NULL, `amount_payment` DOUBLE NULL, PRIMARY KEY (`customer_id`,`datetime_payment`), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Lessons` ( `lesson_id` INTEGER PRIMARY KEY, `customer_id` INTEGER NOT NULL, `lesson_status_code` VARCHAR(15) NOT NULL, `staff_id` INTEGER, `vehicle_id` INTEGER NOT NULL, `lesson_date` DATETIME, `lesson_time` VARCHAR(10), `price` DOUBLE NULL, FOREIGN KEY (`vehicle_id` ) REFERENCES `Vehicles`(`vehicle_id` ), FOREIGN KEY (`staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) )
How long is the total lesson time took by the customer named Rylan Goodwin?
SELECT sum(T1.lesson_time) FROM Lessons AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id WHERE T2.first_name = "Rylan" AND T2.last_name = "Goodwin";
1
driving_school
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_address_id` INTEGER NOT NULL, `nickname` VARCHAR(80), `first_name` VARCHAR(80), `middle_name` VARCHAR(80), `last_name` VARCHAR(80), `date_of_birth` DATETIME, `date_joined_staff` DATETIME, `date_left_staff` DATETIME, FOREIGN KEY (`staff_address_id` ) REFERENCES `Addresses`(`address_id` ) ); CREATE TABLE `Vehicles` ( `vehicle_id` INTEGER PRIMARY KEY, `vehicle_details` VARCHAR(255) ); CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `customer_address_id` INTEGER NOT NULL, `customer_status_code` VARCHAR(15) NOT NULL, `date_became_customer` DATETIME, `date_of_birth` DATETIME, `first_name` VARCHAR(80), `last_name` VARCHAR(80), `amount_outstanding` DOUBLE NULL, `email_address` VARCHAR(250), `phone_number` VARCHAR(255), `cell_mobile_phone_number` VARCHAR(255), FOREIGN KEY (`customer_address_id` ) REFERENCES `Addresses`(`address_id` ) ); CREATE TABLE `Customer_Payments` ( `customer_id` INTEGER NOT NULL, `datetime_payment` DATETIME NOT NULL, `payment_method_code` VARCHAR(10) NOT NULL, `amount_payment` DOUBLE NULL, PRIMARY KEY (`customer_id`,`datetime_payment`), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Lessons` ( `lesson_id` INTEGER PRIMARY KEY, `customer_id` INTEGER NOT NULL, `lesson_status_code` VARCHAR(15) NOT NULL, `staff_id` INTEGER, `vehicle_id` INTEGER NOT NULL, `lesson_date` DATETIME, `lesson_time` VARCHAR(10), `price` DOUBLE NULL, FOREIGN KEY (`vehicle_id` ) REFERENCES `Vehicles`(`vehicle_id` ), FOREIGN KEY (`staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) )
What is the zip code of staff with first name as Janessa and last name as Sawayn lived?
SELECT T1.zip_postcode FROM Addresses AS T1 JOIN Staff AS T2 ON T1.address_id = T2.staff_address_id WHERE T2.first_name = "Janessa" AND T2.last_name = "Sawayn";
1
driving_school
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_address_id` INTEGER NOT NULL, `nickname` VARCHAR(80), `first_name` VARCHAR(80), `middle_name` VARCHAR(80), `last_name` VARCHAR(80), `date_of_birth` DATETIME, `date_joined_staff` DATETIME, `date_left_staff` DATETIME, FOREIGN KEY (`staff_address_id` ) REFERENCES `Addresses`(`address_id` ) ); CREATE TABLE `Vehicles` ( `vehicle_id` INTEGER PRIMARY KEY, `vehicle_details` VARCHAR(255) ); CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `customer_address_id` INTEGER NOT NULL, `customer_status_code` VARCHAR(15) NOT NULL, `date_became_customer` DATETIME, `date_of_birth` DATETIME, `first_name` VARCHAR(80), `last_name` VARCHAR(80), `amount_outstanding` DOUBLE NULL, `email_address` VARCHAR(250), `phone_number` VARCHAR(255), `cell_mobile_phone_number` VARCHAR(255), FOREIGN KEY (`customer_address_id` ) REFERENCES `Addresses`(`address_id` ) ); CREATE TABLE `Customer_Payments` ( `customer_id` INTEGER NOT NULL, `datetime_payment` DATETIME NOT NULL, `payment_method_code` VARCHAR(10) NOT NULL, `amount_payment` DOUBLE NULL, PRIMARY KEY (`customer_id`,`datetime_payment`), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Lessons` ( `lesson_id` INTEGER PRIMARY KEY, `customer_id` INTEGER NOT NULL, `lesson_status_code` VARCHAR(15) NOT NULL, `staff_id` INTEGER, `vehicle_id` INTEGER NOT NULL, `lesson_date` DATETIME, `lesson_time` VARCHAR(10), `price` DOUBLE NULL, FOREIGN KEY (`vehicle_id` ) REFERENCES `Vehicles`(`vehicle_id` ), FOREIGN KEY (`staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) )
What is the zip code of the hosue of the employee named Janessa Sawayn?
SELECT T1.zip_postcode FROM Addresses AS T1 JOIN Staff AS T2 ON T1.address_id = T2.staff_address_id WHERE T2.first_name = "Janessa" AND T2.last_name = "Sawayn";
1
driving_school
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_address_id` INTEGER NOT NULL, `nickname` VARCHAR(80), `first_name` VARCHAR(80), `middle_name` VARCHAR(80), `last_name` VARCHAR(80), `date_of_birth` DATETIME, `date_joined_staff` DATETIME, `date_left_staff` DATETIME, FOREIGN KEY (`staff_address_id` ) REFERENCES `Addresses`(`address_id` ) ); CREATE TABLE `Vehicles` ( `vehicle_id` INTEGER PRIMARY KEY, `vehicle_details` VARCHAR(255) ); CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `customer_address_id` INTEGER NOT NULL, `customer_status_code` VARCHAR(15) NOT NULL, `date_became_customer` DATETIME, `date_of_birth` DATETIME, `first_name` VARCHAR(80), `last_name` VARCHAR(80), `amount_outstanding` DOUBLE NULL, `email_address` VARCHAR(250), `phone_number` VARCHAR(255), `cell_mobile_phone_number` VARCHAR(255), FOREIGN KEY (`customer_address_id` ) REFERENCES `Addresses`(`address_id` ) ); CREATE TABLE `Customer_Payments` ( `customer_id` INTEGER NOT NULL, `datetime_payment` DATETIME NOT NULL, `payment_method_code` VARCHAR(10) NOT NULL, `amount_payment` DOUBLE NULL, PRIMARY KEY (`customer_id`,`datetime_payment`), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Lessons` ( `lesson_id` INTEGER PRIMARY KEY, `customer_id` INTEGER NOT NULL, `lesson_status_code` VARCHAR(15) NOT NULL, `staff_id` INTEGER, `vehicle_id` INTEGER NOT NULL, `lesson_date` DATETIME, `lesson_time` VARCHAR(10), `price` DOUBLE NULL, FOREIGN KEY (`vehicle_id` ) REFERENCES `Vehicles`(`vehicle_id` ), FOREIGN KEY (`staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) )
How many staff live in state Georgia?
SELECT count(*) FROM Addresses WHERE state_province_county = "Georgia";
1
driving_school
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_address_id` INTEGER NOT NULL, `nickname` VARCHAR(80), `first_name` VARCHAR(80), `middle_name` VARCHAR(80), `last_name` VARCHAR(80), `date_of_birth` DATETIME, `date_joined_staff` DATETIME, `date_left_staff` DATETIME, FOREIGN KEY (`staff_address_id` ) REFERENCES `Addresses`(`address_id` ) ); CREATE TABLE `Vehicles` ( `vehicle_id` INTEGER PRIMARY KEY, `vehicle_details` VARCHAR(255) ); CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `customer_address_id` INTEGER NOT NULL, `customer_status_code` VARCHAR(15) NOT NULL, `date_became_customer` DATETIME, `date_of_birth` DATETIME, `first_name` VARCHAR(80), `last_name` VARCHAR(80), `amount_outstanding` DOUBLE NULL, `email_address` VARCHAR(250), `phone_number` VARCHAR(255), `cell_mobile_phone_number` VARCHAR(255), FOREIGN KEY (`customer_address_id` ) REFERENCES `Addresses`(`address_id` ) ); CREATE TABLE `Customer_Payments` ( `customer_id` INTEGER NOT NULL, `datetime_payment` DATETIME NOT NULL, `payment_method_code` VARCHAR(10) NOT NULL, `amount_payment` DOUBLE NULL, PRIMARY KEY (`customer_id`,`datetime_payment`), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Lessons` ( `lesson_id` INTEGER PRIMARY KEY, `customer_id` INTEGER NOT NULL, `lesson_status_code` VARCHAR(15) NOT NULL, `staff_id` INTEGER, `vehicle_id` INTEGER NOT NULL, `lesson_date` DATETIME, `lesson_time` VARCHAR(10), `price` DOUBLE NULL, FOREIGN KEY (`vehicle_id` ) REFERENCES `Vehicles`(`vehicle_id` ), FOREIGN KEY (`staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) )
How many employees live in Georgia?
SELECT count(*) FROM Addresses WHERE state_province_county = "Georgia";
1
driving_school
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_address_id` INTEGER NOT NULL, `nickname` VARCHAR(80), `first_name` VARCHAR(80), `middle_name` VARCHAR(80), `last_name` VARCHAR(80), `date_of_birth` DATETIME, `date_joined_staff` DATETIME, `date_left_staff` DATETIME, FOREIGN KEY (`staff_address_id` ) REFERENCES `Addresses`(`address_id` ) ); CREATE TABLE `Vehicles` ( `vehicle_id` INTEGER PRIMARY KEY, `vehicle_details` VARCHAR(255) ); CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `customer_address_id` INTEGER NOT NULL, `customer_status_code` VARCHAR(15) NOT NULL, `date_became_customer` DATETIME, `date_of_birth` DATETIME, `first_name` VARCHAR(80), `last_name` VARCHAR(80), `amount_outstanding` DOUBLE NULL, `email_address` VARCHAR(250), `phone_number` VARCHAR(255), `cell_mobile_phone_number` VARCHAR(255), FOREIGN KEY (`customer_address_id` ) REFERENCES `Addresses`(`address_id` ) ); CREATE TABLE `Customer_Payments` ( `customer_id` INTEGER NOT NULL, `datetime_payment` DATETIME NOT NULL, `payment_method_code` VARCHAR(10) NOT NULL, `amount_payment` DOUBLE NULL, PRIMARY KEY (`customer_id`,`datetime_payment`), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Lessons` ( `lesson_id` INTEGER PRIMARY KEY, `customer_id` INTEGER NOT NULL, `lesson_status_code` VARCHAR(15) NOT NULL, `staff_id` INTEGER, `vehicle_id` INTEGER NOT NULL, `lesson_date` DATETIME, `lesson_time` VARCHAR(10), `price` DOUBLE NULL, FOREIGN KEY (`vehicle_id` ) REFERENCES `Vehicles`(`vehicle_id` ), FOREIGN KEY (`staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) )
Find out the first name and last name of staff lived in city Damianfort.
SELECT T2.first_name , T2.last_name FROM Addresses AS T1 JOIN Staff AS T2 ON T1.address_id = T2.staff_address_id WHERE T1.city = "Damianfort";