Question: What is the checking balance of the account whose owner’s name contains the substring ‘ee’?

Context: CREATE TABLE checking (balance VARCHAR, custid VARCHAR); CREATE TABLE accounts (custid VARCHAR, name VARCHAR)

Answer: [SQL] SELECT T2.balance FROM accounts AS T1 JOIN checking AS T2 ON T1.custid = T2.custid WHERE T1.name LIKE '%ee%' [/SQL]


Question: Find the checking balance and saving balance in the Brown’s account.

Context: CREATE TABLE checking (balance VARCHAR, custid VARCHAR); CREATE TABLE accounts (custid VARCHAR, name VARCHAR); CREATE TABLE savings (balance VARCHAR, custid VARCHAR)

Answer: [SQL] SELECT T2.balance, T3.balance FROM accounts AS T1 JOIN checking AS T2 ON T1.custid = T2.custid JOIN savings AS T3 ON T1.custid = T3.custid WHERE T1.name = 'Brown' [/SQL]


Question: Find the names of accounts whose checking balance is above the average checking balance, but savings balance is below the average savings balance.

Context: CREATE TABLE checking (custid VARCHAR, balance INTEGER); CREATE TABLE savings (custid VARCHAR, balance INTEGER); CREATE TABLE savings (balance INTEGER); CREATE TABLE checking (balance INTEGER); CREATE TABLE accounts (name VARCHAR, custid VARCHAR)

Answer: [SQL] SELECT T1.name FROM accounts AS T1 JOIN checking AS T2 ON T1.custid = T2.custid WHERE T2.balance > (SELECT AVG(balance) FROM checking) INTERSECT SELECT T1.name FROM accounts AS T1 JOIN savings AS T2 ON T1.custid = T2.custid WHERE T2.balance < (SELECT AVG(balance) FROM savings) [/SQL]


Question: Find the checking balance of the accounts whose savings balance is higher than the average savings balance.

Context: CREATE TABLE accounts (custid VARCHAR, name VARCHAR); CREATE TABLE checking (balance INTEGER, custid VARCHAR); CREATE TABLE savings (balance INTEGER, custid VARCHAR); CREATE TABLE savings (balance INTEGER)

Answer: [SQL] SELECT T2.balance FROM accounts AS T1 JOIN checking AS T2 ON T1.custid = T2.custid WHERE T1.name IN (SELECT T1.name FROM accounts AS T1 JOIN savings AS T2 ON T1.custid = T2.custid WHERE T2.balance > (SELECT AVG(balance) FROM savings)) [/SQL]


Question: List all customers’ names in the alphabetical order.

Context: CREATE TABLE accounts (name VARCHAR)

Answer: [SQL] SELECT name FROM accounts ORDER BY name [/SQL]


Question: Find the name of account that has the lowest total checking and saving balance.

Context: CREATE TABLE checking (custid VARCHAR, balance VARCHAR); CREATE TABLE savings (custid VARCHAR, balance VARCHAR); CREATE TABLE accounts (name VARCHAR, custid VARCHAR)

Answer: [SQL] SELECT T1.name FROM accounts AS T1 JOIN checking AS T2 ON T1.custid = T2.custid JOIN savings AS T3 ON T1.custid = T3.custid ORDER BY T2.balance + T3.balance LIMIT 1 [/SQL]


Question: Find the names and total checking and savings balances of accounts whose savings balance is higher than the average savings balance.

Context: CREATE TABLE checking (balance INTEGER, custid VARCHAR); CREATE TABLE savings (balance INTEGER, custid VARCHAR); CREATE TABLE savings (balance INTEGER); CREATE TABLE accounts (name VARCHAR, custid VARCHAR)

Answer: [SQL] SELECT T1.name, T2.balance + T3.balance FROM accounts AS T1 JOIN checking AS T2 ON T1.custid = T2.custid JOIN savings AS T3 ON T1.custid = T3.custid WHERE T3.balance > (SELECT AVG(balance) FROM savings) [/SQL]


Question: Find the name and checking balance of the account with the lowest savings balance.

Context: CREATE TABLE checking (balance VARCHAR, custid VARCHAR); CREATE TABLE savings (custid VARCHAR, balance VARCHAR); CREATE TABLE accounts (name VARCHAR, custid VARCHAR)

Answer: [SQL] SELECT T1.name, T2.balance FROM accounts AS T1 JOIN checking AS T2 ON T1.custid = T2.custid JOIN savings AS T3 ON T1.custid = T3.custid ORDER BY T3.balance LIMIT 1 [/SQL]


Question: Find the number of checking accounts for each account name.

Context: CREATE TABLE checking (custid VARCHAR); CREATE TABLE accounts (name VARCHAR, custid VARCHAR)

Answer: [SQL] SELECT COUNT(*), T1.name FROM accounts AS T1 JOIN checking AS T2 ON T1.custid = T2.custid GROUP BY T1.name [/SQL]


Question: Find the total saving balance for each account name.

Context: CREATE TABLE savings (balance INTEGER, custid VARCHAR); CREATE TABLE accounts (name VARCHAR, custid VARCHAR)

Answer: [SQL] SELECT SUM(T2.balance), T1.name FROM accounts AS T1 JOIN savings AS T2 ON T1.custid = T2.custid GROUP BY T1.name [/SQL]


Question: Find the name of accounts whose checking balance is below the average checking balance.

Context: CREATE TABLE accounts (name VARCHAR, custid VARCHAR); CREATE TABLE checking (balance INTEGER); CREATE TABLE checking (custid VARCHAR, balance INTEGER)

Answer: [SQL] SELECT T1.name FROM accounts AS T1 JOIN checking AS T2 ON T1.custid = T2.custid WHERE T2.balance < (SELECT AVG(balance) FROM checking) [/SQL]


Question: Find the saving balance of the account with the highest checking balance.

Context: CREATE TABLE savings (balance VARCHAR, custid VARCHAR); CREATE TABLE checking (custid VARCHAR, balance VARCHAR); CREATE TABLE accounts (custid VARCHAR)

Answer: [SQL] SELECT T3.balance FROM accounts AS T1 JOIN checking AS T2 ON T1.custid = T2.custid JOIN savings AS T3 ON T1.custid = T3.custid ORDER BY T2.balance DESC LIMIT 1 [/SQL]


Question: Find the total checking and saving balance of all accounts sorted by the total balance in ascending order.

Context: CREATE TABLE checking (balance VARCHAR, custid VARCHAR); CREATE TABLE savings (balance VARCHAR, custid VARCHAR)

Answer: [SQL] SELECT T1.balance + T2.balance FROM checking AS T1 JOIN savings AS T2 ON T1.custid = T2.custid ORDER BY T1.balance + T2.balance [/SQL]


Question: Find the name and checking balance of the account with the lowest saving balance.

Answer: [SQL] SELECT T2.balance, T1.name FROM accounts AS T1 JOIN checking AS T2 ON T1.custid = T2.custid JOIN savings AS T3 ON T1.custid = T3.custid ORDER BY T3.balance LIMIT 1 [/SQL]


Question: Find the name, checking balance and saving balance of all accounts in the bank.

Context: CREATE TABLE checking (balance VARCHAR, custid VARCHAR); CREATE TABLE savings (balance VARCHAR, custid VARCHAR); CREATE TABLE accounts (name VARCHAR, custid VARCHAR)

Answer: [SQL] SELECT T2.balance, T3.balance, T1.name FROM accounts AS T1 JOIN checking AS T2 ON T1.custid = T2.custid JOIN savings AS T3 ON T1.custid = T3.custid [/SQL]


Question: Find the name, checking balance and savings balance of all accounts in the bank sorted by their total checking and savings balance in descending order.

Answer: [SQL] SELECT T2.balance, T3.balance, T1.name FROM accounts AS T1 JOIN checking AS T2 ON T1.custid = T2.custid JOIN savings AS T3 ON T1.custid = T3.custid ORDER BY T2.balance + T3.balance DESC [/SQL]


Question: Find the name of accounts whose checking balance is higher than corresponding saving balance.

Context: CREATE TABLE savings (custid VARCHAR, balance INTEGER); CREATE TABLE accounts (name VARCHAR, custid VARCHAR); CREATE TABLE checking (custid VARCHAR, balance INTEGER)

Answer: [SQL] SELECT T1.name FROM accounts AS T1 JOIN checking AS T2 ON T1.custid = T2.custid JOIN savings AS T3 ON T1.custid = T3.custid WHERE T2.balance > T3.balance [/SQL]


Question: Find the name and total checking and savings balance of the accounts whose savings balance is lower than corresponding checking balance.

Context: CREATE TABLE checking (balance INTEGER, custid VARCHAR); CREATE TABLE savings (balance INTEGER, custid VARCHAR); CREATE TABLE accounts (name VARCHAR, custid VARCHAR)

Answer: [SQL] SELECT T1.name, T3.balance + T2.balance FROM accounts AS T1 JOIN checking AS T2 ON T1.custid = T2.custid JOIN savings AS T3 ON T1.custid = T3.custid WHERE T3.balance < T2.balance [/SQL]


Question: Find the name and savings balance of the top 3 accounts with the highest saving balance sorted by savings balance in descending order.

Context: CREATE TABLE savings (balance VARCHAR, custid VARCHAR); CREATE TABLE accounts (name VARCHAR, custid VARCHAR)

Answer: [SQL] SELECT T1.name, T2.balance FROM accounts AS T1 JOIN savings AS T2 ON T1.custid = T2.custid ORDER BY T2.balance DESC LIMIT 3 [/SQL]


Question: How many main stream browsers whose market share is at least 5 exist?

Context: CREATE TABLE browser (market_share VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM browser WHERE market_share >= 5 [/SQL]


Question: List the name of browsers in descending order by market share.

Context: CREATE TABLE browser (name VARCHAR, market_share VARCHAR)

Answer: [SQL] SELECT name FROM browser ORDER BY market_share DESC [/SQL]


Question: List the ids, names and market shares of all browsers.

Context: CREATE TABLE browser (id VARCHAR, name VARCHAR, market_share VARCHAR)

Answer: [SQL] SELECT id, name, market_share FROM browser [/SQL]


Question: What is the maximum, minimum and average market share of the listed browsers?

Context: CREATE TABLE browser (market_share INTEGER)

Answer: [SQL] SELECT MAX(market_share), MIN(market_share), AVG(market_share) FROM browser [/SQL]


Question: What is the id and market share of the browser Safari?

Context: CREATE TABLE browser (id VARCHAR, market_share VARCHAR, name VARCHAR)

Answer: [SQL] SELECT id, market_share FROM browser WHERE name = 'Safari' [/SQL]


Question: What are the name and os of web client accelerators that do not work with only a 'Broadband' type connection?

Context: CREATE TABLE web_client_accelerator (name VARCHAR, operating_system VARCHAR, CONNECTION VARCHAR)

Answer: [SQL] SELECT name, operating_system FROM web_client_accelerator WHERE CONNECTION <> 'Broadband' [/SQL]


Question: What is the name of the browser that became compatible with the accelerator 'CProxy' after year 1998 ?

Context: CREATE TABLE accelerator_compatible_browser (browser_id VARCHAR, accelerator_id VARCHAR, compatible_since_year VARCHAR); CREATE TABLE web_client_accelerator (id VARCHAR, name VARCHAR); CREATE TABLE browser (name VARCHAR, id VARCHAR)

Answer: [SQL] SELECT T1.name FROM browser AS T1 JOIN accelerator_compatible_browser AS T2 ON T1.id = T2.browser_id JOIN web_client_accelerator AS T3 ON T2.accelerator_id = T3.id WHERE T3.name = 'CProxy' AND T2.compatible_since_year > 1998 [/SQL]


Question: What are the ids and names of the web accelerators that are compatible with two or more browsers?

Context: CREATE TABLE accelerator_compatible_browser (accelerator_id VARCHAR); CREATE TABLE web_client_accelerator (id VARCHAR, Name VARCHAR)

Answer: [SQL] SELECT T1.id, T1.Name FROM web_client_accelerator AS T1 JOIN accelerator_compatible_browser AS T2 ON T2.accelerator_id = T1.id GROUP BY T1.id HAVING COUNT(*) >= 2 [/SQL]


Question: What is the id and name of the browser that is compatible with the most web accelerators?

Context: CREATE TABLE browser (id VARCHAR, name VARCHAR); CREATE TABLE accelerator_compatible_browser (browser_id VARCHAR)

Answer: [SQL] SELECT T1.id, T1.name FROM browser AS T1 JOIN accelerator_compatible_browser AS T2 ON T1.id = T2.browser_id GROUP BY T1.id ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: When did the web accelerator 'CACHEbox' and browser 'Internet Explorer' become compatible?

Context: CREATE TABLE accelerator_compatible_browser (compatible_since_year VARCHAR, browser_id VARCHAR, accelerator_id VARCHAR); CREATE TABLE browser (id VARCHAR, name VARCHAR); CREATE TABLE web_client_accelerator (id VARCHAR, name VARCHAR)

Answer: [SQL] SELECT T1.compatible_since_year FROM accelerator_compatible_browser AS T1 JOIN browser AS T2 ON T1.browser_id = T2.id JOIN web_client_accelerator AS T3 ON T1.accelerator_id = T3.id WHERE T3.name = 'CACHEbox' AND T2.name = 'Internet Explorer' [/SQL]


Question: How many different kinds of clients are supported by the web clients accelerators?

Context: CREATE TABLE web_client_accelerator (client VARCHAR)

Answer: [SQL] SELECT COUNT(DISTINCT client) FROM web_client_accelerator [/SQL]


Question: How many accelerators are not compatible with the browsers listed ?

Context: CREATE TABLE accelerator_compatible_browser (id VARCHAR, accelerator_id VARCHAR); CREATE TABLE web_client_accelerator (id VARCHAR, accelerator_id VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM web_client_accelerator WHERE NOT id IN (SELECT accelerator_id FROM accelerator_compatible_browser) [/SQL]


Question: What distinct accelerator names are compatible with the browswers that have market share higher than 15?

Context: CREATE TABLE web_client_accelerator (name VARCHAR, id VARCHAR); CREATE TABLE accelerator_compatible_browser (accelerator_id VARCHAR, browser_id VARCHAR); CREATE TABLE browser (id VARCHAR, market_share INTEGER)

Answer: [SQL] SELECT DISTINCT T1.name FROM web_client_accelerator AS T1 JOIN accelerator_compatible_browser AS T2 ON T2.accelerator_id = T1.id JOIN browser AS T3 ON T2.browser_id = T3.id WHERE T3.market_share > 15 [/SQL]


Question: List the names of the browser that are compatible with both 'CACHEbox' and 'Fasterfox'.

Context: CREATE TABLE accelerator_compatible_browser (accelerator_id VARCHAR, browser_id VARCHAR); CREATE TABLE web_client_accelerator (id VARCHAR, name VARCHAR); CREATE TABLE browser (name VARCHAR, id VARCHAR)

Answer: [SQL] SELECT T3.name FROM web_client_accelerator AS T1 JOIN accelerator_compatible_browser AS T2 ON T2.accelerator_id = T1.id JOIN browser AS T3 ON T2.browser_id = T3.id WHERE T1.name = 'CACHEbox' INTERSECT SELECT T3.name FROM web_client_accelerator AS T1 JOIN accelerator_compatible_browser AS T2 ON T2.accelerator_id = T1.id JOIN browser AS T3 ON T2.browser_id = T3.id WHERE T1.name = 'Fasterfox' [/SQL]


Question: Show the accelerator names and supporting operating systems that are not compatible with the browser named 'Opera'.

Context: CREATE TABLE browser (id VARCHAR, name VARCHAR); CREATE TABLE web_client_accelerator (name VARCHAR, operating_system VARCHAR); CREATE TABLE accelerator_compatible_browser (accelerator_id VARCHAR, browser_id VARCHAR); CREATE TABLE web_client_accelerator (name VARCHAR, operating_system VARCHAR, id VARCHAR)

Answer: [SQL] SELECT name, operating_system FROM web_client_accelerator EXCEPT SELECT T1.name, T1.operating_system FROM web_client_accelerator AS T1 JOIN accelerator_compatible_browser AS T2 ON T2.accelerator_id = T1.id JOIN browser AS T3 ON T2.browser_id = T3.id WHERE T3.name = 'Opera' [/SQL]


Question: Which accelerator name contains substring "Opera"?

Context: CREATE TABLE web_client_accelerator (name VARCHAR)

Answer: [SQL] SELECT name FROM web_client_accelerator WHERE name LIKE "%Opera%" [/SQL]


Question: Find the number of web accelerators used for each Operating system.

Context: CREATE TABLE web_client_accelerator (Operating_system VARCHAR)

Answer: [SQL] SELECT Operating_system, COUNT(*) FROM web_client_accelerator GROUP BY Operating_system [/SQL]


Question: give me names of all compatible browsers and accelerators in the descending order of compatible year

Context: CREATE TABLE accelerator_compatible_browser (browser_id VARCHAR, accelerator_id VARCHAR, compatible_since_year VARCHAR); CREATE TABLE web_client_accelerator (name VARCHAR, id VARCHAR); CREATE TABLE browser (name VARCHAR, id VARCHAR)

Answer: [SQL] SELECT T2.name, T3.name FROM accelerator_compatible_browser AS T1 JOIN browser AS T2 ON T1.browser_id = T2.id JOIN web_client_accelerator AS T3 ON T1.accelerator_id = T3.id ORDER BY T1.compatible_since_year DESC [/SQL]


Question: How many wrestlers are there?

Context: CREATE TABLE wrestler (Id VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM wrestler [/SQL]


Question: List the names of wrestlers in descending order of days held.

Context: CREATE TABLE wrestler (Name VARCHAR, Days_held VARCHAR)

Answer: [SQL] SELECT Name FROM wrestler ORDER BY Days_held DESC [/SQL]


Question: What is the name of the wrestler with the fewest days held?

Answer: [SQL] SELECT Name FROM wrestler ORDER BY Days_held LIMIT 1 [/SQL]


Question: What are the distinct reigns of wrestlers whose location is not "Tokyo,Japan" ?

Context: CREATE TABLE wrestler (Reign VARCHAR, LOCATION VARCHAR)

Answer: [SQL] SELECT DISTINCT Reign FROM wrestler WHERE LOCATION <> "Tokyo , Japan" [/SQL]


Question: What are the names and location of the wrestlers?

Context: CREATE TABLE wrestler (Name VARCHAR, LOCATION VARCHAR)

Answer: [SQL] SELECT Name, LOCATION FROM wrestler [/SQL]


Question: What are the elimination moves of wrestlers whose team is "Team Orton"?

Context: CREATE TABLE Elimination (Elimination_Move VARCHAR, Team VARCHAR)

Answer: [SQL] SELECT Elimination_Move FROM Elimination WHERE Team = "Team Orton" [/SQL]


Question: What are the names of wrestlers and the elimination moves?

Context: CREATE TABLE wrestler (Name VARCHAR, Wrestler_ID VARCHAR); CREATE TABLE elimination (Elimination_Move VARCHAR, Wrestler_ID VARCHAR)

Answer: [SQL] SELECT T2.Name, T1.Elimination_Move FROM elimination AS T1 JOIN wrestler AS T2 ON T1.Wrestler_ID = T2.Wrestler_ID [/SQL]


Question: List the names of wrestlers and the teams in elimination in descending order of days held.

Context: CREATE TABLE elimination (Team VARCHAR, Wrestler_ID VARCHAR); CREATE TABLE wrestler (Name VARCHAR, Wrestler_ID VARCHAR, Days_held VARCHAR)

Answer: [SQL] SELECT T2.Name, T1.Team FROM elimination AS T1 JOIN wrestler AS T2 ON T1.Wrestler_ID = T2.Wrestler_ID ORDER BY T2.Days_held DESC [/SQL]


Question: List the time of elimination of the wrestlers with largest days held.

Context: CREATE TABLE wrestler (Wrestler_ID VARCHAR, Days_held VARCHAR); CREATE TABLE elimination (Time VARCHAR, Wrestler_ID VARCHAR)

Answer: [SQL] SELECT T1.Time FROM elimination AS T1 JOIN wrestler AS T2 ON T1.Wrestler_ID = T2.Wrestler_ID ORDER BY T2.Days_held DESC LIMIT 1 [/SQL]


Question: Show times of elimination of wrestlers with days held more than 50.

Context: CREATE TABLE wrestler (Wrestler_ID VARCHAR, Days_held INTEGER); CREATE TABLE elimination (Time VARCHAR, Wrestler_ID VARCHAR)

Answer: [SQL] SELECT T1.Time FROM elimination AS T1 JOIN wrestler AS T2 ON T1.Wrestler_ID = T2.Wrestler_ID WHERE T2.Days_held > 50 [/SQL]


Question: Show different teams in eliminations and the number of eliminations from each team.

Context: CREATE TABLE elimination (Team VARCHAR)

Answer: [SQL] SELECT Team, COUNT(*) FROM elimination GROUP BY Team [/SQL]


Question: Show teams that have suffered more than three eliminations.

Context: CREATE TABLE elimination (Team VARCHAR)

Answer: [SQL] SELECT Team FROM elimination GROUP BY Team HAVING COUNT(*) > 3 [/SQL]


Question: Show the reign and days held of wrestlers.

Context: CREATE TABLE wrestler (Reign VARCHAR, Days_held VARCHAR)

Answer: [SQL] SELECT Reign, Days_held FROM wrestler [/SQL]


Question: What are the names of wrestlers days held less than 100?

Context: CREATE TABLE wrestler (Name VARCHAR, Days_held INTEGER)

Answer: [SQL] SELECT Name FROM wrestler WHERE Days_held < 100 [/SQL]


Question: Please show the most common reigns of wrestlers.

Context: CREATE TABLE wrestler (Reign VARCHAR)

Answer: [SQL] SELECT Reign FROM wrestler GROUP BY Reign ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: List the locations that are shared by more than two wrestlers.

Context: CREATE TABLE wrestler (LOCATION VARCHAR)

Answer: [SQL] SELECT LOCATION FROM wrestler GROUP BY LOCATION HAVING COUNT(*) > 2 [/SQL]


Question: List the names of wrestlers that have not been eliminated.

Context: CREATE TABLE elimination (Name VARCHAR, Wrestler_ID VARCHAR); CREATE TABLE wrestler (Name VARCHAR, Wrestler_ID VARCHAR)

Answer: [SQL] SELECT Name FROM wrestler WHERE NOT Wrestler_ID IN (SELECT Wrestler_ID FROM elimination) [/SQL]


Question: Show the teams that have both wrestlers eliminated by "Orton" and wrestlers eliminated by "Benjamin".

Context: CREATE TABLE Elimination (Team VARCHAR, Eliminated_By VARCHAR)

Answer: [SQL] SELECT Team FROM Elimination WHERE Eliminated_By = "Orton" INTERSECT SELECT Team FROM Elimination WHERE Eliminated_By = "Benjamin" [/SQL]


Question: What is the number of distinct teams that suffer elimination?

Context: CREATE TABLE elimination (team VARCHAR)

Answer: [SQL] SELECT COUNT(DISTINCT team) FROM elimination [/SQL]


Question: Show the times of elimination by "Punk" or "Orton".

Context: CREATE TABLE elimination (TIME VARCHAR, Eliminated_By VARCHAR)

Answer: [SQL] SELECT TIME FROM elimination WHERE Eliminated_By = "Punk" OR Eliminated_By = "Orton" [/SQL]


Question: How many schools are there?

Context: CREATE TABLE school (Id VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM school [/SQL]


Question: Show all school names in alphabetical order.

Context: CREATE TABLE school (school_name VARCHAR)

Answer: [SQL] SELECT school_name FROM school ORDER BY school_name [/SQL]


Question: List the name, location, mascot for all schools.

Context: CREATE TABLE school (school_name VARCHAR, LOCATION VARCHAR, mascot VARCHAR)

Answer: [SQL] SELECT school_name, LOCATION, mascot FROM school [/SQL]


Question: What are the total and average enrollment of all schools?

Context: CREATE TABLE school (enrollment INTEGER)

Answer: [SQL] SELECT SUM(enrollment), AVG(enrollment) FROM school [/SQL]


Question: What are the mascots for schools with enrollments above the average?

Context: CREATE TABLE school (mascot VARCHAR, enrollment INTEGER)

Answer: [SQL] SELECT mascot FROM school WHERE enrollment > (SELECT AVG(enrollment) FROM school) [/SQL]


Question: List the name of the school with the smallest enrollment.

Context: CREATE TABLE school (school_name VARCHAR, enrollment VARCHAR)

Answer: [SQL] SELECT school_name FROM school ORDER BY enrollment LIMIT 1 [/SQL]


Question: Show the average, maximum, minimum enrollment of all schools.

Answer: [SQL] SELECT AVG(enrollment), MAX(enrollment), MIN(enrollment) FROM school [/SQL]


Question: Show each county along with the number of schools and total enrollment in each county.

Context: CREATE TABLE school (county VARCHAR, enrollment INTEGER)

Answer: [SQL] SELECT county, COUNT(*), SUM(enrollment) FROM school GROUP BY county [/SQL]


Question: How many donors have endowment for school named "Glenn"?

Context: CREATE TABLE school (school_id VARCHAR, school_name VARCHAR); CREATE TABLE endowment (donator_name VARCHAR, school_id VARCHAR)

Answer: [SQL] SELECT COUNT(DISTINCT T1.donator_name) FROM endowment AS T1 JOIN school AS T2 ON T1.school_id = T2.school_id WHERE T2.school_name = "Glenn" [/SQL]


Question: List each donator name and the amount of endowment in descending order of the amount of endowment.

Context: CREATE TABLE endowment (donator_name VARCHAR, amount INTEGER)

Answer: [SQL] SELECT donator_name, SUM(amount) FROM endowment GROUP BY donator_name ORDER BY SUM(amount) DESC [/SQL]


Question: List the names of the schools without any endowment.

Context: CREATE TABLE endowment (school_name VARCHAR, school_id VARCHAR); CREATE TABLE school (school_name VARCHAR, school_id VARCHAR)

Answer: [SQL] SELECT school_name FROM school WHERE NOT school_id IN (SELECT school_id FROM endowment) [/SQL]


Question: List all the names of schools with an endowment amount smaller than or equal to 10.

Context: CREATE TABLE school (school_name VARCHAR, school_id VARCHAR); CREATE TABLE endowment (school_id VARCHAR, amount INTEGER)

Answer: [SQL] SELECT T2.school_name FROM endowment AS T1 JOIN school AS T2 ON T1.school_id = T2.school_id GROUP BY T1.school_id HAVING SUM(T1.amount) <= 10 [/SQL]


Question: Show the names of donors who donated to both school "Glenn" and "Triton."

Answer: [SQL] SELECT T1.donator_name FROM endowment AS T1 JOIN school AS T2 ON T1.school_id = T2.school_id WHERE T2.school_name = 'Glenn' INTERSECT SELECT T1.donator_name FROM endowment AS T1 JOIN school AS T2 ON T1.school_id = T2.school_id WHERE T2.school_name = 'Triton' [/SQL]


Question: Show the names of all the donors except those whose donation amount less than 9.

Answer: [SQL] SELECT donator_name FROM endowment EXCEPT SELECT donator_name FROM endowment WHERE amount < 9 [/SQL]


Question: List the amount and donor name for the largest amount of donation.

Context: CREATE TABLE endowment (amount VARCHAR, donator_name VARCHAR)

Answer: [SQL] SELECT amount, donator_name FROM endowment ORDER BY amount DESC LIMIT 1 [/SQL]


Question: How many budgets are above 3000 in year 2001 or before?

Context: CREATE TABLE budget (budgeted VARCHAR, YEAR VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM budget WHERE budgeted > 3000 AND YEAR <= 2001 [/SQL]


Question: Show each school name, its budgeted amount, and invested amount in year 2002 or after.

Context: CREATE TABLE budget (budgeted VARCHAR, invested VARCHAR, school_id VARCHAR, year VARCHAR); CREATE TABLE school (school_name VARCHAR, school_id VARCHAR)

Answer: [SQL] SELECT T2.school_name, T1.budgeted, T1.invested FROM budget AS T1 JOIN school AS T2 ON T1.school_id = T2.school_id WHERE T1.year >= 2002 [/SQL]


Question: Show all donor names.

Context: CREATE TABLE endowment (donator_name VARCHAR)

Answer: [SQL] SELECT DISTINCT donator_name FROM endowment [/SQL]


Question: How many budget record has a budget amount smaller than the invested amount?

Context: CREATE TABLE budget (budgeted INTEGER, invested VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM budget WHERE budgeted < invested [/SQL]


Question: What is the total budget amount for school "Glenn" in all years?

Context: CREATE TABLE budget (budgeted INTEGER, school_id VARCHAR); CREATE TABLE school (school_id VARCHAR, school_name VARCHAR)

Answer: [SQL] SELECT SUM(T1.budgeted) FROM budget AS T1 JOIN school AS T2 ON T1.school_id = T2.school_id WHERE T2.school_name = 'Glenn' [/SQL]


Question: Show the names of schools with a total budget amount greater than 100 or a total endowment greater than 10.

Context: CREATE TABLE endowment (school_id VARCHAR, amount INTEGER); CREATE TABLE budget (school_id VARCHAR, budgeted INTEGER); CREATE TABLE school (school_name VARCHAR, school_id VARCHAR)

Answer: [SQL] SELECT T2.school_name FROM budget AS T1 JOIN school AS T2 ON T1.school_id = T2.school_id JOIN endowment AS T3 ON T2.school_id = T3.school_id GROUP BY T2.school_name HAVING SUM(T1.budgeted) > 100 OR SUM(T3.amount) > 10 [/SQL]


Question: Find the names of schools that have more than one donator with donation amount above 8.5.

Context: CREATE TABLE school (School_name VARCHAR, school_id VARCHAR); CREATE TABLE endowment (school_id VARCHAR, amount INTEGER)

Answer: [SQL] SELECT T2.School_name FROM endowment AS T1 JOIN school AS T2 ON T1.school_id = T2.school_id WHERE T1.amount > 8.5 GROUP BY T1.school_id HAVING COUNT(*) > 1 [/SQL]


Question: Find the number of schools that have more than one donator whose donation amount is less than 8.5.

Context: CREATE TABLE endowment (school_id VARCHAR, amount INTEGER)

Answer: [SQL] SELECT COUNT(*) FROM (SELECT * FROM endowment WHERE amount > 8.5 GROUP BY school_id HAVING COUNT(*) > 1) [/SQL]


Question: List the name, IHSAA Football Class, and Mascot of the schools that have more than 6000 of budgeted amount or were founded before 2003, in the order of percent of total invested budget and total budgeted budget.

Context: CREATE TABLE school (School_name VARCHAR, Mascot VARCHAR, IHSAA_Football_Class VARCHAR, school_id VARCHAR); CREATE TABLE budget (school_id VARCHAR, total_budget_percent_invested VARCHAR, total_budget_percent_budgeted VARCHAR)

Answer: [SQL] SELECT T1.School_name, T1.Mascot, T1.IHSAA_Football_Class FROM school AS T1 JOIN budget AS T2 ON T1.school_id = T2.school_id WHERE Budgeted > 6000 OR YEAR < 2003 ORDER BY T2.total_budget_percent_invested, T2.total_budget_percent_budgeted [/SQL]


Question: How many buildings are there?

Context: CREATE TABLE building (Id VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM building [/SQL]


Question: Show the name, street address, and number of floors for all buildings ordered by the number of floors.

Context: CREATE TABLE building (name VARCHAR, street_address VARCHAR, floors VARCHAR)

Answer: [SQL] SELECT name, street_address, floors FROM building ORDER BY floors [/SQL]


Question: What is the name of the tallest building?

Context: CREATE TABLE building (name VARCHAR, height_feet VARCHAR)

Answer: [SQL] SELECT name FROM building ORDER BY height_feet DESC LIMIT 1 [/SQL]


Question: What are the average, maximum, and minimum number of floors for all buildings?

Context: CREATE TABLE building (floors INTEGER)

Answer: [SQL] SELECT AVG(floors), MAX(floors), MIN(floors) FROM building [/SQL]


Question: Show the number of buildings with a height above the average or a number of floors above the average.

Context: CREATE TABLE building (height_feet INTEGER, floors INTEGER)

Answer: [SQL] SELECT COUNT(*) FROM building WHERE height_feet > (SELECT AVG(height_feet) FROM building) OR floors > (SELECT AVG(floors) FROM building) [/SQL]


Question: List the names of buildings with at least 200 feet of height and with at least 20 floors.

Context: CREATE TABLE building (name VARCHAR, height_feet VARCHAR, floors VARCHAR)

Answer: [SQL] SELECT name FROM building WHERE height_feet >= 200 AND floors >= 20 [/SQL]


Question: Show the names and locations of institutions that are founded after 1990 and have the type "Private".

Context: CREATE TABLE institution (institution VARCHAR, LOCATION VARCHAR, founded VARCHAR, TYPE VARCHAR)

Answer: [SQL] SELECT institution, LOCATION FROM institution WHERE founded > 1990 AND TYPE = 'Private' [/SQL]


Question: Show institution types, along with the number of institutions and total enrollment for each type.

Context: CREATE TABLE institution (TYPE VARCHAR, enrollment INTEGER)

Answer: [SQL] SELECT TYPE, COUNT(*), SUM(enrollment) FROM institution GROUP BY TYPE [/SQL]


Question: Show the institution type with the largest number of institutions.

Context: CREATE TABLE institution (TYPE VARCHAR)

Answer: [SQL] SELECT TYPE FROM institution GROUP BY TYPE ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: Show the institution type with an institution founded after 1990 and an institution with at least 1000 enrollment.

Context: CREATE TABLE institution (TYPE VARCHAR, founded VARCHAR, enrollment VARCHAR)

Answer: [SQL] SELECT TYPE FROM institution WHERE founded > 1990 AND enrollment >= 1000 [/SQL]


Question: Show the name of buildings that do not have any institution.

Context: CREATE TABLE building (name VARCHAR, building_id VARCHAR); CREATE TABLE institution (name VARCHAR, building_id VARCHAR)

Answer: [SQL] SELECT name FROM building WHERE NOT building_id IN (SELECT building_id FROM institution) [/SQL]


Question: Show the names of buildings except for those having an institution founded in 2003.

Context: CREATE TABLE building (name VARCHAR, building_id VARCHAR); CREATE TABLE building (name VARCHAR); CREATE TABLE institution (building_id VARCHAR, founded VARCHAR)

Answer: [SQL] SELECT name FROM building EXCEPT SELECT T1.name FROM building AS T1 JOIN institution AS T2 ON T1.building_id = T2.building_id WHERE T2.founded = 2003 [/SQL]


Question: For each building, show the name of the building and the number of institutions in it.

Context: CREATE TABLE building (name VARCHAR, building_id VARCHAR); CREATE TABLE institution (building_id VARCHAR)

Answer: [SQL] SELECT T1.name, COUNT(*) FROM building AS T1 JOIN institution AS T2 ON T1.building_id = T2.building_id GROUP BY T1.building_id [/SQL]


Question: Show the names and heights of buildings with at least two institutions founded after 1880.

Context: CREATE TABLE building (name VARCHAR, height_feet VARCHAR, building_id VARCHAR); CREATE TABLE institution (building_id VARCHAR, founded INTEGER)

Answer: [SQL] SELECT T1.name, T1.height_feet FROM building AS T1 JOIN institution AS T2 ON T1.building_id = T2.building_id WHERE T2.founded > 1880 GROUP BY T1.building_id HAVING COUNT(*) >= 2 [/SQL]


Question: Show all the distinct institution types.

Context: CREATE TABLE institution (TYPE VARCHAR)

Answer: [SQL] SELECT DISTINCT TYPE FROM institution [/SQL]


Question: Show institution names along with the number of proteins for each institution.

Context: CREATE TABLE institution (institution VARCHAR, institution_id VARCHAR); CREATE TABLE protein (institution_id VARCHAR)

Answer: [SQL] SELECT T1.institution, COUNT(*) FROM institution AS T1 JOIN protein AS T2 ON T1.institution_id = T2.institution_id GROUP BY T1.institution_id [/SQL]


Question: How many proteins are associated with an institution founded after 1880 or an institution with type "Private"?

Context: CREATE TABLE institution (institution_id VARCHAR, founded VARCHAR, type VARCHAR); CREATE TABLE protein (institution_id VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM institution AS T1 JOIN protein AS T2 ON T1.institution_id = T2.institution_id WHERE T1.founded > 1880 OR T1.type = 'Private' [/SQL]


Question: Show the protein name and the institution name.

Context: CREATE TABLE institution (institution VARCHAR, institution_id VARCHAR); CREATE TABLE protein (protein_name VARCHAR, institution_id VARCHAR)

Answer: [SQL] SELECT T2.protein_name, T1.institution FROM institution AS T1 JOIN protein AS T2 ON T1.institution_id = T2.institution_id [/SQL]


Question: How many proteins are associated with an institution in a building with at least 20 floors?

Context: CREATE TABLE institution (institution_id VARCHAR, building_id VARCHAR); CREATE TABLE building (building_id VARCHAR, floors VARCHAR); CREATE TABLE protein (institution_id VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM institution AS T1 JOIN protein AS T2 ON T1.institution_id = T2.institution_id JOIN building AS T3 ON T3.building_id = T1.building_id WHERE T3.floors >= 20 [/SQL]


Question: How many institutions do not have an associated protein in our record?

Context: CREATE TABLE protein (institution_id VARCHAR); CREATE TABLE institution (institution_id VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM institution WHERE NOT institution_id IN (SELECT institution_id FROM protein) [/SQL]


Question: Show all the locations where no cinema has capacity over 800.

Context: CREATE TABLE cinema (LOCATION VARCHAR, capacity INTEGER)

Answer: [SQL] SELECT LOCATION FROM cinema EXCEPT SELECT LOCATION FROM cinema WHERE capacity > 800 [/SQL]


Question: Show all the locations where some cinemas were opened in both year 2010 and year 2011.

Context: CREATE TABLE cinema (LOCATION VARCHAR, openning_year VARCHAR)

Answer: [SQL] SELECT LOCATION FROM cinema WHERE openning_year = 2010 INTERSECT SELECT LOCATION FROM cinema WHERE openning_year = 2011 [/SQL]


Question: How many cinema do we have?

Context: CREATE TABLE cinema (Id VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM cinema [/SQL]


Question: Show name, opening year, and capacity for each cinema.

Context: CREATE TABLE cinema (name VARCHAR, openning_year VARCHAR, capacity VARCHAR)

Answer: [SQL] SELECT name, openning_year, capacity FROM cinema [/SQL]


Question: Show the cinema name and location for cinemas with capacity above average.

Context: CREATE TABLE cinema (name VARCHAR, LOCATION VARCHAR, capacity INTEGER)

Answer: [SQL] SELECT name, LOCATION FROM cinema WHERE capacity > (SELECT AVG(capacity) FROM cinema) [/SQL]


Question: What are all the locations with a cinema?

Context: CREATE TABLE cinema (LOCATION VARCHAR)

Answer: [SQL] SELECT DISTINCT LOCATION FROM cinema [/SQL]


Question: Show all the cinema names and opening years in descending order of opening year.

Context: CREATE TABLE cinema (name VARCHAR, openning_year VARCHAR)

Answer: [SQL] SELECT name, openning_year FROM cinema ORDER BY openning_year DESC [/SQL]


Question: What are the name and location of the cinema with the largest capacity?

Context: CREATE TABLE cinema (name VARCHAR, LOCATION VARCHAR, capacity VARCHAR)

Answer: [SQL] SELECT name, LOCATION FROM cinema ORDER BY capacity DESC LIMIT 1 [/SQL]


Question: Show the average, minimum, and maximum capacity for all the cinemas opened in year 2011 or later.

Context: CREATE TABLE cinema (capacity INTEGER, openning_year VARCHAR)

Answer: [SQL] SELECT AVG(capacity), MIN(capacity), MAX(capacity) FROM cinema WHERE openning_year >= 2011 [/SQL]


Question: Show each location and the number of cinemas there.

Context: CREATE TABLE cinema (LOCATION VARCHAR)

Answer: [SQL] SELECT LOCATION, COUNT(*) FROM cinema GROUP BY LOCATION [/SQL]


Question: What is the location with the most cinemas opened in year 2010 or later?

Answer: [SQL] SELECT LOCATION FROM cinema WHERE openning_year >= 2010 GROUP BY LOCATION ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: Show all the locations with at least two cinemas with capacity above 300.

Answer: [SQL] SELECT LOCATION FROM cinema WHERE capacity > 300 GROUP BY LOCATION HAVING COUNT(*) >= 2 [/SQL]


Question: Show the title and director for all films.

Context: CREATE TABLE film (title VARCHAR, directed_by VARCHAR)

Answer: [SQL] SELECT title, directed_by FROM film [/SQL]


Question: Show all directors.

Context: CREATE TABLE film (directed_by VARCHAR)

Answer: [SQL] SELECT DISTINCT directed_by FROM film [/SQL]


Question: List all directors along with the number of films directed by each director.

Context: CREATE TABLE film (directed_by VARCHAR)

Answer: [SQL] SELECT directed_by, COUNT(*) FROM film GROUP BY directed_by [/SQL]


Question: What is total number of show times per dat for each cinema?

Context: CREATE TABLE schedule (show_times_per_day INTEGER, cinema_id VARCHAR); CREATE TABLE cinema (name VARCHAR, cinema_id VARCHAR)

Answer: [SQL] SELECT T2.name, SUM(T1.show_times_per_day) FROM schedule AS T1 JOIN cinema AS T2 ON T1.cinema_id = T2.cinema_id GROUP BY T1.cinema_id [/SQL]


Question: What are the title and maximum price of each film?

Context: CREATE TABLE film (title VARCHAR, film_id VARCHAR); CREATE TABLE schedule (price INTEGER, film_id VARCHAR)

Answer: [SQL] SELECT T2.title, MAX(T1.price) FROM schedule AS T1 JOIN film AS T2 ON T1.film_id = T2.film_id GROUP BY T1.film_id [/SQL]


Question: Show cinema name, film title, date, and price for each record in schedule.

Context: CREATE TABLE schedule (date VARCHAR, price VARCHAR, film_id VARCHAR, cinema_id VARCHAR); CREATE TABLE cinema (name VARCHAR, cinema_id VARCHAR); CREATE TABLE film (title VARCHAR, film_id VARCHAR)

Answer: [SQL] SELECT T3.name, T2.title, T1.date, T1.price FROM schedule AS T1 JOIN film AS T2 ON T1.film_id = T2.film_id JOIN cinema AS T3 ON T1.cinema_id = T3.cinema_id [/SQL]


Question: What are the title and director of the films without any schedule?

Context: CREATE TABLE schedule (title VARCHAR, directed_by VARCHAR, film_id VARCHAR); CREATE TABLE film (title VARCHAR, directed_by VARCHAR, film_id VARCHAR)

Answer: [SQL] SELECT title, directed_by FROM film WHERE NOT film_id IN (SELECT film_id FROM schedule) [/SQL]


Question: Show director with the largest number of show times in total.

Context: CREATE TABLE schedule (film_id VARCHAR, show_times_per_day INTEGER); CREATE TABLE film (directed_by VARCHAR, film_id VARCHAR)

Answer: [SQL] SELECT T2.directed_by FROM schedule AS T1 JOIN film AS T2 ON T1.film_id = T2.film_id GROUP BY T2.directed_by ORDER BY SUM(T1.show_times_per_day) DESC LIMIT 1 [/SQL]


Question: Find the locations that have more than one movie theater with capacity above 300.

Answer: [SQL] SELECT LOCATION FROM cinema WHERE capacity > 300 GROUP BY LOCATION HAVING COUNT(*) > 1 [/SQL]


Question: How many films have the word 'Dummy' in their titles?

Context: CREATE TABLE film (title VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM film WHERE title LIKE "%Dummy%" [/SQL]


Question: Are the customers holding coupons with amount 500 bad or good?

Context: CREATE TABLE discount_coupons (coupon_id VARCHAR, coupon_amount VARCHAR); CREATE TABLE customers (good_or_bad_customer VARCHAR, coupon_id VARCHAR)

Answer: [SQL] SELECT T1.good_or_bad_customer FROM customers AS T1 JOIN discount_coupons AS T2 ON T1.coupon_id = T2.coupon_id WHERE T2.coupon_amount = 500 [/SQL]


Question: How many bookings did each customer make? List the customer id, first name, and the count.

Context: CREATE TABLE bookings (customer_id VARCHAR); CREATE TABLE Customers (customer_id VARCHAR, first_name VARCHAR)

Answer: [SQL] SELECT T1.customer_id, T1.first_name, COUNT(*) FROM Customers AS T1 JOIN bookings AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id [/SQL]


Question: What is the maximum total amount paid by a customer? List the customer id and amount.

Context: CREATE TABLE Payments (customer_id VARCHAR, amount_paid INTEGER)

Answer: [SQL] SELECT customer_id, SUM(amount_paid) FROM Payments GROUP BY customer_id ORDER BY SUM(amount_paid) DESC LIMIT 1 [/SQL]


Question: What are the id and the amount of refund of the booking that incurred the most times of payments?

Context: CREATE TABLE Payments (booking_id VARCHAR); CREATE TABLE Bookings (booking_id VARCHAR, amount_of_refund VARCHAR)

Answer: [SQL] SELECT T1.booking_id, T1.amount_of_refund FROM Bookings AS T1 JOIN Payments AS T2 ON T1.booking_id = T2.booking_id GROUP BY T1.booking_id ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: What is the id of the product that is booked for 3 times?

Context: CREATE TABLE products_booked (product_id VARCHAR)

Answer: [SQL] SELECT product_id FROM products_booked GROUP BY product_id HAVING COUNT(*) = 3 [/SQL]


Question: What is the product description of the product booked with an amount of 102.76?

Context: CREATE TABLE products_for_hire (product_description VARCHAR, product_id VARCHAR); CREATE TABLE products_booked (product_id VARCHAR, booked_amount VARCHAR)

Answer: [SQL] SELECT T2.product_description FROM products_booked AS T1 JOIN products_for_hire AS T2 ON T1.product_id = T2.product_id WHERE T1.booked_amount = 102.76 [/SQL]


Question: What are the start date and end date of the booking that has booked the product named 'Book collection A'?

Context: CREATE TABLE bookings (booking_start_date VARCHAR, booking_end_date VARCHAR, booking_id VARCHAR); CREATE TABLE products_booked (product_id VARCHAR, booking_id VARCHAR); CREATE TABLE Products_for_hire (product_id VARCHAR, product_name VARCHAR)

Answer: [SQL] SELECT T3.booking_start_date, T3.booking_end_date FROM Products_for_hire AS T1 JOIN products_booked AS T2 ON T1.product_id = T2.product_id JOIN bookings AS T3 ON T2.booking_id = T3.booking_id WHERE T1.product_name = 'Book collection A' [/SQL]


Question: What are the names of products whose availability equals to 1?

Context: CREATE TABLE view_product_availability (product_id VARCHAR, available_yn VARCHAR); CREATE TABLE products_for_hire (product_name VARCHAR, product_id VARCHAR)

Answer: [SQL] SELECT T2.product_name FROM view_product_availability AS T1 JOIN products_for_hire AS T2 ON T1.product_id = T2.product_id WHERE T1.available_yn = 1 [/SQL]


Question: How many different product types are there?

Context: CREATE TABLE products_for_hire (product_type_code VARCHAR)

Answer: [SQL] SELECT COUNT(DISTINCT product_type_code) FROM products_for_hire [/SQL]


Question: What are the first name, last name, and gender of all the good customers? Order by their last name.

Context: CREATE TABLE customers (first_name VARCHAR, last_name VARCHAR, gender_mf VARCHAR, good_or_bad_customer VARCHAR)

Answer: [SQL] SELECT first_name, last_name, gender_mf FROM customers WHERE good_or_bad_customer = 'good' ORDER BY last_name [/SQL]


Question: What is the average amount due for all the payments?

Context: CREATE TABLE payments (amount_due INTEGER)

Answer: [SQL] SELECT AVG(amount_due) FROM payments [/SQL]


Question: What are the maximum, minimum, and average booked count for the products booked?

Context: CREATE TABLE products_booked (booked_count INTEGER)

Answer: [SQL] SELECT MAX(booked_count), MIN(booked_count), AVG(booked_count) FROM products_booked [/SQL]


Question: What are all the distinct payment types?

Context: CREATE TABLE payments (payment_type_code VARCHAR)

Answer: [SQL] SELECT DISTINCT payment_type_code FROM payments [/SQL]


Question: What are the daily hire costs for the products with substring 'Book' in its name?

Context: CREATE TABLE Products_for_hire (daily_hire_cost VARCHAR, product_name VARCHAR)

Answer: [SQL] SELECT daily_hire_cost FROM Products_for_hire WHERE product_name LIKE '%Book%' [/SQL]


Question: How many products are never booked with amount higher than 200?

Context: CREATE TABLE products_booked (product_id VARCHAR, booked_amount INTEGER); CREATE TABLE Products_for_hire (product_id VARCHAR, booked_amount INTEGER)

Answer: [SQL] SELECT COUNT(*) FROM Products_for_hire WHERE NOT product_id IN (SELECT product_id FROM products_booked WHERE booked_amount > 200) [/SQL]


Question: What are the coupon amount of the coupons owned by both good and bad customers?

Context: CREATE TABLE Discount_Coupons (coupon_amount VARCHAR, coupon_id VARCHAR); CREATE TABLE customers (coupon_id VARCHAR, good_or_bad_customer VARCHAR)

Answer: [SQL] SELECT T1.coupon_amount FROM Discount_Coupons AS T1 JOIN customers AS T2 ON T1.coupon_id = T2.coupon_id WHERE T2.good_or_bad_customer = 'good' INTERSECT SELECT T1.coupon_amount FROM Discount_Coupons AS T1 JOIN customers AS T2 ON T1.coupon_id = T2.coupon_id WHERE T2.good_or_bad_customer = 'bad' [/SQL]


Question: What are the payment date of the payment with amount paid higher than 300 or with payment type is 'Check'

Context: CREATE TABLE payments (payment_date VARCHAR, amount_paid VARCHAR, payment_type_code VARCHAR)

Answer: [SQL] SELECT payment_date FROM payments WHERE amount_paid > 300 OR payment_type_code = 'Check' [/SQL]


Question: What are the names and descriptions of the products that are of 'Cutlery' type and have daily hire cost lower than 20?

Context: CREATE TABLE products_for_hire (product_name VARCHAR, product_description VARCHAR, product_type_code VARCHAR, daily_hire_cost VARCHAR)

Answer: [SQL] SELECT product_name, product_description FROM products_for_hire WHERE product_type_code = 'Cutlery' AND daily_hire_cost < 20 [/SQL]


Question: How many phones are there?

Context: CREATE TABLE phone (Id VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM phone [/SQL]


Question: List the names of phones in ascending order of price.

Context: CREATE TABLE phone (Name VARCHAR, Price VARCHAR)

Answer: [SQL] SELECT Name FROM phone ORDER BY Price [/SQL]


Question: What are the memories and carriers of phones?

Context: CREATE TABLE phone (Memory_in_G VARCHAR, Carrier VARCHAR)

Answer: [SQL] SELECT Memory_in_G, Carrier FROM phone [/SQL]


Question: List the distinct carriers of phones with memories bigger than 32.

Context: CREATE TABLE phone (Carrier VARCHAR, Memory_in_G INTEGER)

Answer: [SQL] SELECT DISTINCT Carrier FROM phone WHERE Memory_in_G > 32 [/SQL]


Question: Show the names of phones with carrier either "Sprint" or "TMobile".

Context: CREATE TABLE phone (Name VARCHAR, Carrier VARCHAR)

Answer: [SQL] SELECT Name FROM phone WHERE Carrier = "Sprint" OR Carrier = "TMobile" [/SQL]


Question: What is the carrier of the most expensive phone?

Context: CREATE TABLE phone (Carrier VARCHAR, Price VARCHAR)

Answer: [SQL] SELECT Carrier FROM phone ORDER BY Price DESC LIMIT 1 [/SQL]


Question: Show different carriers of phones together with the number of phones with each carrier.

Context: CREATE TABLE phone (Carrier VARCHAR)

Answer: [SQL] SELECT Carrier, COUNT(*) FROM phone GROUP BY Carrier [/SQL]


Question: Show the most frequently used carrier of the phones.

Context: CREATE TABLE phone (Carrier VARCHAR)

Answer: [SQL] SELECT Carrier FROM phone GROUP BY Carrier ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: Show the carriers that have both phones with memory smaller than 32 and phones with memory bigger than 64.

Answer: [SQL] SELECT Carrier FROM phone WHERE Memory_in_G < 32 INTERSECT SELECT Carrier FROM phone WHERE Memory_in_G > 64 [/SQL]


Question: Show the names of phones and the districts of markets they are on.

Context: CREATE TABLE phone (Name VARCHAR, Phone_ID VARCHAR); CREATE TABLE market (District VARCHAR, Market_ID VARCHAR); CREATE TABLE phone_market (Market_ID VARCHAR, Phone_ID VARCHAR)

Answer: [SQL] SELECT T3.Name, T2.District FROM phone_market AS T1 JOIN market AS T2 ON T1.Market_ID = T2.Market_ID JOIN phone AS T3 ON T1.Phone_ID = T3.Phone_ID [/SQL]


Question: Show the names of phones and the districts of markets they are on, in ascending order of the ranking of the market.

Context: CREATE TABLE market (District VARCHAR, Market_ID VARCHAR, Ranking VARCHAR); CREATE TABLE phone (Name VARCHAR, Phone_ID VARCHAR); CREATE TABLE phone_market (Market_ID VARCHAR, Phone_ID VARCHAR)

Answer: [SQL] SELECT T3.Name, T2.District FROM phone_market AS T1 JOIN market AS T2 ON T1.Market_ID = T2.Market_ID JOIN phone AS T3 ON T1.Phone_ID = T3.Phone_ID ORDER BY T2.Ranking [/SQL]


Question: Show the names of phones that are on market with number of shops greater than 50.

Context: CREATE TABLE market (Market_ID VARCHAR, Num_of_shops INTEGER); CREATE TABLE phone (Name VARCHAR, Phone_ID VARCHAR); CREATE TABLE phone_market (Market_ID VARCHAR, Phone_ID VARCHAR)

Answer: [SQL] SELECT T3.Name FROM phone_market AS T1 JOIN market AS T2 ON T1.Market_ID = T2.Market_ID JOIN phone AS T3 ON T1.Phone_ID = T3.Phone_ID WHERE T2.Num_of_shops > 50 [/SQL]


Question: For each phone, show its names and total number of stocks.

Context: CREATE TABLE phone_market (Num_of_stock INTEGER, Phone_ID VARCHAR); CREATE TABLE phone (Name VARCHAR, Phone_ID VARCHAR)

Answer: [SQL] SELECT T2.Name, SUM(T1.Num_of_stock) FROM phone_market AS T1 JOIN phone AS T2 ON T1.Phone_ID = T2.Phone_ID GROUP BY T2.Name [/SQL]


Question: Show the names of phones that have total number of stocks bigger than 2000, in descending order of the total number of stocks.

Context: CREATE TABLE phone_market (Phone_ID VARCHAR, Num_of_stock INTEGER); CREATE TABLE phone (Name VARCHAR, Phone_ID VARCHAR)

Answer: [SQL] SELECT T2.Name FROM phone_market AS T1 JOIN phone AS T2 ON T1.Phone_ID = T2.Phone_ID GROUP BY T2.Name HAVING SUM(T1.Num_of_stock) >= 2000 ORDER BY SUM(T1.Num_of_stock) DESC [/SQL]


Question: List the names of phones that are not on any market.

Context: CREATE TABLE phone (Name VARCHAR, Phone_id VARCHAR, Phone_ID VARCHAR); CREATE TABLE phone_market (Name VARCHAR, Phone_id VARCHAR, Phone_ID VARCHAR)

Answer: [SQL] SELECT Name FROM phone WHERE NOT Phone_id IN (SELECT Phone_ID FROM phone_market) [/SQL]


Question: How many gas companies are there?

Context: CREATE TABLE company (Id VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM company [/SQL]


Question: List the company name and rank for all companies in the decreasing order of their sales.

Context: CREATE TABLE company (company VARCHAR, rank VARCHAR, Sales_billion VARCHAR)

Answer: [SQL] SELECT company, rank FROM company ORDER BY Sales_billion DESC [/SQL]


Question: Show the company name and the main industry for all companies whose headquarters are not from USA.

Context: CREATE TABLE company (company VARCHAR, main_industry VARCHAR, headquarters VARCHAR)

Answer: [SQL] SELECT company, main_industry FROM company WHERE headquarters <> 'USA' [/SQL]


Question: Show all company names and headquarters in the descending order of market value.

Context: CREATE TABLE company (company VARCHAR, headquarters VARCHAR, market_value VARCHAR)

Answer: [SQL] SELECT company, headquarters FROM company ORDER BY market_value DESC [/SQL]


Question: Show minimum, maximum, and average market value for all companies.

Context: CREATE TABLE company (market_value INTEGER)

Answer: [SQL] SELECT MIN(market_value), MAX(market_value), AVG(market_value) FROM company [/SQL]


Question: Show all main industry for all companies.

Context: CREATE TABLE company (main_industry VARCHAR)

Answer: [SQL] SELECT DISTINCT main_industry FROM company [/SQL]


Question: List all headquarters and the number of companies in each headquarter.

Context: CREATE TABLE company (headquarters VARCHAR)

Answer: [SQL] SELECT headquarters, COUNT(*) FROM company GROUP BY headquarters [/SQL]


Question: Show all main industry and total market value in each industry.

Context: CREATE TABLE company (main_industry VARCHAR, market_value INTEGER)

Answer: [SQL] SELECT main_industry, SUM(market_value) FROM company GROUP BY main_industry [/SQL]


Question: List the main industry with highest total market value and its number of companies.

Answer: [SQL] SELECT main_industry, COUNT(*) FROM company GROUP BY main_industry ORDER BY SUM(market_value) DESC LIMIT 1 [/SQL]


Question: Show headquarters with at least two companies in the banking industry.

Context: CREATE TABLE company (headquarters VARCHAR, main_industry VARCHAR)

Answer: [SQL] SELECT headquarters FROM company WHERE main_industry = 'Banking' GROUP BY headquarters HAVING COUNT(*) >= 2 [/SQL]


Question: Show gas station id, location, and manager_name for all gas stations ordered by open year.

Context: CREATE TABLE gas_station (station_id VARCHAR, LOCATION VARCHAR, manager_name VARCHAR, open_year VARCHAR)

Answer: [SQL] SELECT station_id, LOCATION, manager_name FROM gas_station ORDER BY open_year [/SQL]


Question: How many gas station are opened between 2000 and 2005?

Context: CREATE TABLE gas_station (open_year INTEGER)

Answer: [SQL] SELECT COUNT(*) FROM gas_station WHERE open_year BETWEEN 2000 AND 2005 [/SQL]


Question: Show all locations and the number of gas stations in each location ordered by the count.

Context: CREATE TABLE gas_station (LOCATION VARCHAR)

Answer: [SQL] SELECT LOCATION, COUNT(*) FROM gas_station GROUP BY LOCATION ORDER BY COUNT(*) [/SQL]


Question: Show all headquarters with both a company in banking industry and a company in Oil and gas.

Answer: [SQL] SELECT headquarters FROM company WHERE main_industry = 'Banking' INTERSECT SELECT headquarters FROM company WHERE main_industry = 'Oil and gas' [/SQL]


Question: Show all headquarters without a company in banking industry.

Answer: [SQL] SELECT headquarters FROM company EXCEPT SELECT headquarters FROM company WHERE main_industry = 'Banking' [/SQL]


Question: Show the company name with the number of gas station.

Context: CREATE TABLE station_company (company_id VARCHAR); CREATE TABLE company (company VARCHAR, company_id VARCHAR)

Answer: [SQL] SELECT T2.company, COUNT(*) FROM station_company AS T1 JOIN company AS T2 ON T1.company_id = T2.company_id GROUP BY T1.company_id [/SQL]


Question: Show company name and main industry without a gas station.

Context: CREATE TABLE station_company (company VARCHAR, main_industry VARCHAR, company_id VARCHAR); CREATE TABLE company (company VARCHAR, main_industry VARCHAR, company_id VARCHAR)

Answer: [SQL] SELECT company, main_industry FROM company WHERE NOT company_id IN (SELECT company_id FROM station_company) [/SQL]


Question: Show the manager name for gas stations belonging to the ExxonMobil company.

Context: CREATE TABLE gas_station (manager_name VARCHAR, station_id VARCHAR); CREATE TABLE station_company (company_id VARCHAR, station_id VARCHAR); CREATE TABLE company (company_id VARCHAR, company VARCHAR)

Answer: [SQL] SELECT T3.manager_name FROM station_company AS T1 JOIN company AS T2 ON T1.company_id = T2.company_id JOIN gas_station AS T3 ON T1.station_id = T3.station_id WHERE T2.company = 'ExxonMobil' [/SQL]


Question: Show all locations where a gas station for company with market value greater than 100 is located.

Context: CREATE TABLE gas_station (location VARCHAR, station_id VARCHAR); CREATE TABLE company (company_id VARCHAR, market_value INTEGER); CREATE TABLE station_company (company_id VARCHAR, station_id VARCHAR)

Answer: [SQL] SELECT T3.location FROM station_company AS T1 JOIN company AS T2 ON T1.company_id = T2.company_id JOIN gas_station AS T3 ON T1.station_id = T3.station_id WHERE T2.market_value > 100 [/SQL]


Question: Show the manager name with most number of gas stations opened after 2000.

Context: CREATE TABLE gas_station (manager_name VARCHAR, open_year INTEGER)

Answer: [SQL] SELECT manager_name FROM gas_station WHERE open_year > 2000 GROUP BY manager_name ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: order all gas station locations by the opening year.

Context: CREATE TABLE gas_station (LOCATION VARCHAR, open_year VARCHAR)

Answer: [SQL] SELECT LOCATION FROM gas_station ORDER BY open_year [/SQL]


Question: find the rank, company names, market values of the companies in the banking industry order by their sales and profits in billion.

Context: CREATE TABLE company (rank VARCHAR, company VARCHAR, market_value VARCHAR, main_industry VARCHAR, sales_billion VARCHAR, profits_billion VARCHAR)

Answer: [SQL] SELECT rank, company, market_value FROM company WHERE main_industry = 'Banking' ORDER BY sales_billion, profits_billion [/SQL]


Question: find the location and Representative name of the gas stations owned by the companies with top 3 Asset amounts.

Context: CREATE TABLE gas_station (location VARCHAR, Representative_Name VARCHAR, station_id VARCHAR); CREATE TABLE station_company (company_id VARCHAR, station_id VARCHAR); CREATE TABLE company (company_id VARCHAR, Assets_billion VARCHAR)

Answer: [SQL] SELECT T3.location, T3.Representative_Name FROM station_company AS T1 JOIN company AS T2 ON T1.company_id = T2.company_id JOIN gas_station AS T3 ON T1.station_id = T3.station_id ORDER BY T2.Assets_billion DESC LIMIT 3 [/SQL]


Question: How many regions do we have?

Context: CREATE TABLE region (Id VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM region [/SQL]


Question: Show all distinct region names ordered by their labels.

Context: CREATE TABLE region (region_name VARCHAR, Label VARCHAR)

Answer: [SQL] SELECT DISTINCT region_name FROM region ORDER BY Label [/SQL]


Question: How many parties do we have?

Context: CREATE TABLE party (party_name VARCHAR)

Answer: [SQL] SELECT COUNT(DISTINCT party_name) FROM party [/SQL]


Question: Show the ministers and the time they took and left office, listed by the time they left office.

Context: CREATE TABLE party (minister VARCHAR, took_office VARCHAR, left_office VARCHAR)

Answer: [SQL] SELECT minister, took_office, left_office FROM party ORDER BY left_office [/SQL]


Question: Show the minister who took office after 1961 or before 1959.

Context: CREATE TABLE party (minister VARCHAR, took_office VARCHAR)

Answer: [SQL] SELECT minister FROM party WHERE took_office > 1961 OR took_office < 1959 [/SQL]


Question: Show all ministers who do not belong to Progress Party.

Context: CREATE TABLE party (minister VARCHAR, party_name VARCHAR)

Answer: [SQL] SELECT minister FROM party WHERE party_name <> 'Progress Party' [/SQL]


Question: Show all ministers and parties they belong to in descending order of the time they took office.

Context: CREATE TABLE party (minister VARCHAR, party_name VARCHAR, took_office VARCHAR)

Answer: [SQL] SELECT minister, party_name FROM party ORDER BY took_office DESC [/SQL]


Question: Return the minister who left office at the latest time.

Context: CREATE TABLE party (minister VARCHAR, left_office VARCHAR)

Answer: [SQL] SELECT minister FROM party ORDER BY left_office DESC LIMIT 1 [/SQL]


Question: List member names and their party names.

Context: CREATE TABLE party (party_name VARCHAR, party_id VARCHAR); CREATE TABLE Member (member_name VARCHAR, party_id VARCHAR)

Answer: [SQL] SELECT T1.member_name, T2.party_name FROM Member AS T1 JOIN party AS T2 ON T1.party_id = T2.party_id [/SQL]


Question: Show all party names and the number of members in each party.

Context: CREATE TABLE party (party_name VARCHAR, party_id VARCHAR); CREATE TABLE Member (party_id VARCHAR)

Answer: [SQL] SELECT T2.party_name, COUNT(*) FROM Member AS T1 JOIN party AS T2 ON T1.party_id = T2.party_id GROUP BY T1.party_id [/SQL]


Question: What is the name of party with most number of members?

Answer: [SQL] SELECT T2.party_name FROM Member AS T1 JOIN party AS T2 ON T1.party_id = T2.party_id GROUP BY T1.party_id ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: Show all party names and their region names.

Context: CREATE TABLE region (region_name VARCHAR, region_id VARCHAR); CREATE TABLE party (party_name VARCHAR, region_id VARCHAR)

Answer: [SQL] SELECT T1.party_name, T2.region_name FROM party AS T1 JOIN region AS T2 ON T1.region_id = T2.region_id [/SQL]


Question: Show names of parties that does not have any members.

Context: CREATE TABLE party (party_name VARCHAR, party_id VARCHAR); CREATE TABLE Member (party_name VARCHAR, party_id VARCHAR)

Answer: [SQL] SELECT party_name FROM party WHERE NOT party_id IN (SELECT party_id FROM Member) [/SQL]


Question: Show the member names which are in both the party with id 3 and the party with id 1.

Context: CREATE TABLE member (member_name VARCHAR, party_id VARCHAR)

Answer: [SQL] SELECT member_name FROM member WHERE party_id = 3 INTERSECT SELECT member_name FROM member WHERE party_id = 1 [/SQL]


Question: Show member names that are not in the Progress Party.

Context: CREATE TABLE party (party_id VARCHAR, Party_name VARCHAR); CREATE TABLE Member (member_name VARCHAR, party_id VARCHAR)

Answer: [SQL] SELECT T1.member_name FROM Member AS T1 JOIN party AS T2 ON T1.party_id = T2.party_id WHERE T2.Party_name <> "Progress Party" [/SQL]


Question: How many party events do we have?

Context: CREATE TABLE party_events (Id VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM party_events [/SQL]


Question: Show party names and the number of events for each party.

Context: CREATE TABLE party (party_name VARCHAR, party_id VARCHAR); CREATE TABLE party_events (party_id VARCHAR)

Answer: [SQL] SELECT T2.party_name, COUNT(*) FROM party_events AS T1 JOIN party AS T2 ON T1.party_id = T2.party_id GROUP BY T1.party_id [/SQL]


Question: Show all member names who are not in charge of any event.

Context: CREATE TABLE member (member_name VARCHAR); CREATE TABLE party_events (member_in_charge_id VARCHAR); CREATE TABLE member (member_name VARCHAR, member_id VARCHAR)

Answer: [SQL] SELECT member_name FROM member EXCEPT SELECT T1.member_name FROM member AS T1 JOIN party_events AS T2 ON T1.member_id = T2.member_in_charge_id [/SQL]


Question: What are the names of parties with at least 2 events?

Answer: [SQL] SELECT T2.party_name FROM party_events AS T1 JOIN party AS T2 ON T1.party_id = T2.party_id GROUP BY T1.party_id HAVING COUNT(*) >= 2 [/SQL]


Question: What is the name of member in charge of greatest number of events?

Context: CREATE TABLE party_events (member_in_charge_id VARCHAR); CREATE TABLE member (member_name VARCHAR, member_id VARCHAR)

Answer: [SQL] SELECT T1.member_name FROM member AS T1 JOIN party_events AS T2 ON T1.member_id = T2.member_in_charge_id GROUP BY T2.member_in_charge_id ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: find the event names that have more than 2 records.

Context: CREATE TABLE party_events (event_name VARCHAR)

Answer: [SQL] SELECT event_name FROM party_events GROUP BY event_name HAVING COUNT(*) > 2 [/SQL]


Question: How many Annual Meeting events happened in the United Kingdom region?

Context: CREATE TABLE party_events (party_id VARCHAR, Event_Name VARCHAR); CREATE TABLE region (region_id VARCHAR, region_name VARCHAR); CREATE TABLE party (region_id VARCHAR, party_id VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM region AS t1 JOIN party AS t2 ON t1.region_id = t2.region_id JOIN party_events AS t3 ON t2.party_id = t3.party_id WHERE t1.region_name = "United Kingdom" AND t3.Event_Name = "Annaual Meeting" [/SQL]


Question: How many pilots are there?

Context: CREATE TABLE pilot (Id VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM pilot [/SQL]


Question: List the names of pilots in ascending order of rank.

Context: CREATE TABLE pilot (Pilot_name VARCHAR, Rank VARCHAR)

Answer: [SQL] SELECT Pilot_name FROM pilot ORDER BY Rank [/SQL]


Question: What are the positions and teams of pilots?

Context: CREATE TABLE pilot (POSITION VARCHAR, Team VARCHAR)

Answer: [SQL] SELECT POSITION, Team FROM pilot [/SQL]


Question: List the distinct positions of pilots older than 30.

Context: CREATE TABLE pilot (POSITION VARCHAR, Age INTEGER)

Answer: [SQL] SELECT DISTINCT POSITION FROM pilot WHERE Age > 30 [/SQL]


Question: Show the names of pilots from team "Bradley" or "Fordham".

Context: CREATE TABLE pilot (Pilot_name VARCHAR, Team VARCHAR)

Answer: [SQL] SELECT Pilot_name FROM pilot WHERE Team = "Bradley" OR Team = "Fordham" [/SQL]


Question: What is the joined year of the pilot of the highest rank?

Context: CREATE TABLE pilot (Join_Year VARCHAR, Rank VARCHAR)

Answer: [SQL] SELECT Join_Year FROM pilot ORDER BY Rank LIMIT 1 [/SQL]


Question: What are the different nationalities of pilots? Show each nationality and the number of pilots of each nationality.

Context: CREATE TABLE pilot (Nationality VARCHAR)

Answer: [SQL] SELECT Nationality, COUNT(*) FROM pilot GROUP BY Nationality [/SQL]


Question: Show the most common nationality of pilots.

Answer: [SQL] SELECT Nationality FROM pilot GROUP BY Nationality ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: Show the pilot positions that have both pilots joining after year 2005 and pilots joining before 2000.

Context: CREATE TABLE pilot (POSITION VARCHAR, Join_Year INTEGER)

Answer: [SQL] SELECT POSITION FROM pilot WHERE Join_Year < 2000 INTERSECT SELECT POSITION FROM pilot WHERE Join_Year > 2005 [/SQL]


Question: Show the names of pilots and models of aircrafts they have flied with.

Context: CREATE TABLE pilot_record (Aircraft_ID VARCHAR, Pilot_ID VARCHAR); CREATE TABLE pilot (Pilot_name VARCHAR, Pilot_ID VARCHAR); CREATE TABLE aircraft (Model VARCHAR, Aircraft_ID VARCHAR)

Answer: [SQL] SELECT T3.Pilot_name, T2.Model FROM pilot_record AS T1 JOIN aircraft AS T2 ON T1.Aircraft_ID = T2.Aircraft_ID JOIN pilot AS T3 ON T1.Pilot_ID = T3.Pilot_ID [/SQL]


Question: Show the names of pilots and fleet series of the aircrafts they have flied with in ascending order of the rank of the pilot.

Context: CREATE TABLE pilot (Pilot_name VARCHAR, Pilot_ID VARCHAR, Rank VARCHAR); CREATE TABLE pilot_record (Aircraft_ID VARCHAR, Pilot_ID VARCHAR); CREATE TABLE aircraft (Fleet_Series VARCHAR, Aircraft_ID VARCHAR)

Answer: [SQL] SELECT T3.Pilot_name, T2.Fleet_Series FROM pilot_record AS T1 JOIN aircraft AS T2 ON T1.Aircraft_ID = T2.Aircraft_ID JOIN pilot AS T3 ON T1.Pilot_ID = T3.Pilot_ID ORDER BY T3.Rank [/SQL]


Question: Show the fleet series of the aircrafts flied by pilots younger than 34

Context: CREATE TABLE pilot_record (Aircraft_ID VARCHAR, Pilot_ID VARCHAR); CREATE TABLE pilot (Pilot_ID VARCHAR, Age INTEGER); CREATE TABLE aircraft (Fleet_Series VARCHAR, Aircraft_ID VARCHAR)

Answer: [SQL] SELECT T2.Fleet_Series FROM pilot_record AS T1 JOIN aircraft AS T2 ON T1.Aircraft_ID = T2.Aircraft_ID JOIN pilot AS T3 ON T1.Pilot_ID = T3.Pilot_ID WHERE T3.Age < 34 [/SQL]


Question: Show the names of pilots and the number of records they have.

Context: CREATE TABLE pilot (Pilot_name VARCHAR, pilot_ID VARCHAR); CREATE TABLE pilot_record (pilot_ID VARCHAR)

Answer: [SQL] SELECT T2.Pilot_name, COUNT(*) FROM pilot_record AS T1 JOIN pilot AS T2 ON T1.pilot_ID = T2.pilot_ID GROUP BY T2.Pilot_name [/SQL]


Question: Show names of pilots that have more than one record.

Answer: [SQL] SELECT T2.Pilot_name, COUNT(*) FROM pilot_record AS T1 JOIN pilot AS T2 ON T1.pilot_ID = T2.pilot_ID GROUP BY T2.Pilot_name HAVING COUNT(*) > 1 [/SQL]


Question: List the names of pilots that do not have any record.

Context: CREATE TABLE pilot_record (Pilot_name VARCHAR, Pilot_ID VARCHAR); CREATE TABLE pilot (Pilot_name VARCHAR, Pilot_ID VARCHAR)

Answer: [SQL] SELECT Pilot_name FROM pilot WHERE NOT Pilot_ID IN (SELECT Pilot_ID FROM pilot_record) [/SQL]


Question: What document status codes do we have?

Context: CREATE TABLE Ref_Document_Status (document_status_code VARCHAR)

Answer: [SQL] SELECT document_status_code FROM Ref_Document_Status [/SQL]


Question: What is the description of document status code 'working'?

Context: CREATE TABLE Ref_Document_Status (document_status_description VARCHAR, document_status_code VARCHAR)

Answer: [SQL] SELECT document_status_description FROM Ref_Document_Status WHERE document_status_code = "working" [/SQL]


Question: What document type codes do we have?

Context: CREATE TABLE Ref_Document_Types (document_type_code VARCHAR)

Answer: [SQL] SELECT document_type_code FROM Ref_Document_Types [/SQL]


Question: What is the description of document type 'Paper'?

Context: CREATE TABLE Ref_Document_Types (document_type_description VARCHAR, document_type_code VARCHAR)

Answer: [SQL] SELECT document_type_description FROM Ref_Document_Types WHERE document_type_code = "Paper" [/SQL]


Question: What are the shipping agent names?

Context: CREATE TABLE Ref_Shipping_Agents (shipping_agent_name VARCHAR)

Answer: [SQL] SELECT shipping_agent_name FROM Ref_Shipping_Agents [/SQL]


Question: What is the shipping agent code of shipping agent UPS?

Context: CREATE TABLE Ref_Shipping_Agents (shipping_agent_code VARCHAR, shipping_agent_name VARCHAR)

Answer: [SQL] SELECT shipping_agent_code FROM Ref_Shipping_Agents WHERE shipping_agent_name = "UPS" [/SQL]


Question: What are all role codes?

Context: CREATE TABLE ROLES (role_code VARCHAR)

Answer: [SQL] SELECT role_code FROM ROLES [/SQL]


Question: What is the description of role code ED?

Context: CREATE TABLE ROLES (role_description VARCHAR, role_code VARCHAR)

Answer: [SQL] SELECT role_description FROM ROLES WHERE role_code = "ED" [/SQL]


Question: How many employees do we have?

Context: CREATE TABLE Employees (Id VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM Employees [/SQL]


Question: What is the role of the employee named Koby?

Context: CREATE TABLE ROLES (role_description VARCHAR, role_code VARCHAR); CREATE TABLE Employees (role_code VARCHAR, employee_name VARCHAR)

Answer: [SQL] SELECT T1.role_description FROM ROLES AS T1 JOIN Employees AS T2 ON T1.role_code = T2.role_code WHERE T2.employee_name = "Koby" [/SQL]


Question: List all document ids and receipt dates of documents.

Context: CREATE TABLE Documents (document_id VARCHAR, receipt_date VARCHAR)

Answer: [SQL] SELECT document_id, receipt_date FROM Documents [/SQL]


Question: How many employees does each role have? List role description, id and number of employees.

Context: CREATE TABLE ROLES (role_description VARCHAR, role_code VARCHAR); CREATE TABLE Employees (role_code VARCHAR)

Answer: [SQL] SELECT T1.role_description, T2.role_code, COUNT(*) FROM ROLES AS T1 JOIN Employees AS T2 ON T1.role_code = T2.role_code GROUP BY T2.role_code [/SQL]


Question: List roles that have more than one employee. List the role description and number of employees.

Context: CREATE TABLE ROLES (Id VARCHAR); CREATE TABLE Employees (Id VARCHAR)

Answer: [SQL] SELECT Roles.role_description, COUNT(Employees.employee_id) FROM ROLES JOIN Employees ON Employees.role_code = Roles.role_code GROUP BY Employees.role_code HAVING COUNT(Employees.employee_id) > 1 [/SQL]


Question: What is the document status description of the document with id 1?

Context: CREATE TABLE Documents (Id VARCHAR); CREATE TABLE Ref_Document_Status (Id VARCHAR)

Answer: [SQL] SELECT Ref_Document_Status.document_status_description FROM Ref_Document_Status JOIN Documents ON Documents.document_status_code = Ref_Document_Status.document_status_code WHERE Documents.document_id = 1 [/SQL]


Question: How many documents have the status code done?

Context: CREATE TABLE Documents (document_status_code VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM Documents WHERE document_status_code = "done" [/SQL]


Question: List the document type code for the document with the id 2.

Context: CREATE TABLE Documents (document_type_code VARCHAR, document_id VARCHAR)

Answer: [SQL] SELECT document_type_code FROM Documents WHERE document_id = 2 [/SQL]


Question: List the document ids for any documents with the status code done and the type code paper.

Context: CREATE TABLE Documents (document_id VARCHAR, document_status_code VARCHAR, document_type_code VARCHAR)

Answer: [SQL] SELECT document_id FROM Documents WHERE document_status_code = "done" AND document_type_code = "Paper" [/SQL]


Question: What is the name of the shipping agent of the document with id 2?

Context: CREATE TABLE Documents (Id VARCHAR); CREATE TABLE Ref_Shipping_Agents (Id VARCHAR)

Answer: [SQL] SELECT Ref_Shipping_Agents.shipping_agent_name FROM Ref_Shipping_Agents JOIN Documents ON Documents.shipping_agent_code = Ref_Shipping_Agents.shipping_agent_code WHERE Documents.document_id = 2 [/SQL]


Question: How many documents were shipped by USPS?

Answer: [SQL] SELECT COUNT(*) FROM Ref_Shipping_Agents JOIN Documents ON Documents.shipping_agent_code = Ref_Shipping_Agents.shipping_agent_code WHERE Ref_Shipping_Agents.shipping_agent_name = "USPS" [/SQL]


Question: Which shipping agent shipped the most documents? List the shipping agent name and the number of documents.

Answer: [SQL] SELECT Ref_Shipping_Agents.shipping_agent_name, COUNT(Documents.document_id) FROM Ref_Shipping_Agents JOIN Documents ON Documents.shipping_agent_code = Ref_Shipping_Agents.shipping_agent_code GROUP BY Ref_Shipping_Agents.shipping_agent_code ORDER BY COUNT(Documents.document_id) DESC LIMIT 1 [/SQL]


Question: What is the receipt date of the document with id 3?

Context: CREATE TABLE Documents (receipt_date VARCHAR, document_id VARCHAR)

Answer: [SQL] SELECT receipt_date FROM Documents WHERE document_id = 3 [/SQL]


Question: What address was the document with id 4 mailed to?

Context: CREATE TABLE Addresses (document_id VARCHAR); CREATE TABLE Documents_Mailed (document_id VARCHAR)

Answer: [SQL] SELECT Addresses.address_details FROM Addresses JOIN Documents_Mailed ON Documents_Mailed.mailed_to_address_id = Addresses.address_id WHERE document_id = 4 [/SQL]


Question: What is the mail date of the document with id 7?

Context: CREATE TABLE Documents_Mailed (mailing_date VARCHAR, document_id VARCHAR)

Answer: [SQL] SELECT mailing_date FROM Documents_Mailed WHERE document_id = 7 [/SQL]


Question: List the document ids of documents with the status done and type Paper, which not shipped by the shipping agent named USPS.

Context: CREATE TABLE Ref_Shipping_Agents (document_id VARCHAR, document_status_code VARCHAR, document_type_code VARCHAR); CREATE TABLE Documents (document_id VARCHAR, document_status_code VARCHAR, document_type_code VARCHAR)

Answer: [SQL] SELECT document_id FROM Documents WHERE document_status_code = "done" AND document_type_code = "Paper" EXCEPT SELECT document_id FROM Documents JOIN Ref_Shipping_Agents ON Documents.shipping_agent_code = Ref_Shipping_Agents.shipping_agent_code WHERE Ref_Shipping_Agents.shipping_agent_name = "USPS" [/SQL]


Question: List document id of documents status is done and document type is Paper and the document is shipped by shipping agent named USPS.

Answer: [SQL] SELECT document_id FROM Documents WHERE document_status_code = "done" AND document_type_code = "Paper" INTERSECT SELECT document_id FROM Documents JOIN Ref_Shipping_Agents ON Documents.shipping_agent_code = Ref_Shipping_Agents.shipping_agent_code WHERE Ref_Shipping_Agents.shipping_agent_name = "USPS" [/SQL]


Question: What is draft detail of the document with id 7?

Context: CREATE TABLE Document_Drafts (draft_details VARCHAR, document_id VARCHAR)

Answer: [SQL] SELECT draft_details FROM Document_Drafts WHERE document_id = 7 [/SQL]


Question: How many draft copies does the document with id 2 have?

Context: CREATE TABLE Draft_Copies (document_id VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM Draft_Copies WHERE document_id = 2 [/SQL]


Question: Which document has the most draft copies? List its document id and number of draft copies.

Context: CREATE TABLE Draft_Copies (document_id VARCHAR, copy_number VARCHAR)

Answer: [SQL] SELECT document_id, COUNT(copy_number) FROM Draft_Copies GROUP BY document_id ORDER BY COUNT(copy_number) DESC LIMIT 1 [/SQL]


Question: Which documents have more than 1 draft copies? List document id and number of draft copies.

Answer: [SQL] SELECT document_id, COUNT(*) FROM Draft_Copies GROUP BY document_id HAVING COUNT(*) > 1 [/SQL]


Question: List all employees in the circulation history of the document with id 1. List the employee's name.

Context: CREATE TABLE Circulation_History (Id VARCHAR); CREATE TABLE Employees (Id VARCHAR)

Answer: [SQL] SELECT Employees.employee_name FROM Employees JOIN Circulation_History ON Circulation_History.employee_id = Employees.employee_id WHERE Circulation_History.document_id = 1 [/SQL]


Question: List the employees who have not showed up in any circulation history of documents. List the employee's name.

Context: CREATE TABLE Circulation_History (employee_name VARCHAR); CREATE TABLE Employees (employee_name VARCHAR)

Answer: [SQL] SELECT employee_name FROM Employees EXCEPT SELECT Employees.employee_name FROM Employees JOIN Circulation_History ON Circulation_History.employee_id = Employees.employee_id [/SQL]


Question: Which employee has showed up in most circulation history documents. List the employee's name and the number of drafts and copies.

Answer: [SQL] SELECT Employees.employee_name, COUNT(*) FROM Employees JOIN Circulation_History ON Circulation_History.employee_id = Employees.employee_id GROUP BY Circulation_History.document_id, Circulation_History.draft_number, Circulation_History.copy_number ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: For each document, list the number of employees who have showed up in the circulation history of that document. List the document ids and number of employees.

Context: CREATE TABLE Circulation_History (document_id VARCHAR, employee_id VARCHAR)

Answer: [SQL] SELECT document_id, COUNT(DISTINCT employee_id) FROM Circulation_History GROUP BY document_id [/SQL]


Question: List all department names ordered by their starting date.

Context: CREATE TABLE department (dname VARCHAR, mgr_start_date VARCHAR)

Answer: [SQL] SELECT dname FROM department ORDER BY mgr_start_date [/SQL]


Question: find all dependent names who have a spouse relation with some employee.

Context: CREATE TABLE dependent (Dependent_name VARCHAR, relationship VARCHAR)

Answer: [SQL] SELECT Dependent_name FROM dependent WHERE relationship = 'Spouse' [/SQL]


Question: how many female dependents are there?

Context: CREATE TABLE dependent (sex VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM dependent WHERE sex = 'F' [/SQL]


Question: Find the names of departments that are located in Houston.

Context: CREATE TABLE dept_locations (dnumber VARCHAR, dlocation VARCHAR); CREATE TABLE department (dname VARCHAR, dnumber VARCHAR)

Answer: [SQL] SELECT t1.dname FROM department AS t1 JOIN dept_locations AS t2 ON t1.dnumber = t2.dnumber WHERE t2.dlocation = 'Houston' [/SQL]


Question: Return the first names and last names of employees who earn more than 30000 in salary.

Context: CREATE TABLE employee (fname VARCHAR, lname VARCHAR, salary INTEGER)

Answer: [SQL] SELECT fname, lname FROM employee WHERE salary > 30000 [/SQL]


Question: Find the number of employees of each gender whose salary is lower than 50000.

Context: CREATE TABLE employee (sex VARCHAR, salary INTEGER)

Answer: [SQL] SELECT COUNT(*), sex FROM employee WHERE salary < 50000 GROUP BY sex [/SQL]


Question: list the first and last names, and the addresses of all employees in the ascending order of their birth date.

Context: CREATE TABLE employee (fname VARCHAR, lname VARCHAR, address VARCHAR, Bdate VARCHAR)

Answer: [SQL] SELECT fname, lname, address FROM employee ORDER BY Bdate [/SQL]


Question: what are the event details of the services that have the type code 'Marriage'?

Context: CREATE TABLE EVENTS (event_details VARCHAR, Service_ID VARCHAR); CREATE TABLE Services (Service_ID VARCHAR, Service_Type_Code VARCHAR)

Answer: [SQL] SELECT T1.event_details FROM EVENTS AS T1 JOIN Services AS T2 ON T1.Service_ID = T2.Service_ID WHERE T2.Service_Type_Code = 'Marriage' [/SQL]


Question: What are the ids and details of events that have more than one participants?

Context: CREATE TABLE EVENTS (event_id VARCHAR, event_details VARCHAR, Event_ID VARCHAR); CREATE TABLE Participants_in_Events (Event_ID VARCHAR)

Answer: [SQL] SELECT T1.event_id, T1.event_details FROM EVENTS AS T1 JOIN Participants_in_Events AS T2 ON T1.Event_ID = T2.Event_ID GROUP BY T1.Event_ID HAVING COUNT(*) > 1 [/SQL]


Question: How many events have each participants attended? List the participant id, type and the number.

Context: CREATE TABLE Participants (Participant_ID VARCHAR, Participant_Type_Code VARCHAR); CREATE TABLE Participants_in_Events (Participant_ID VARCHAR)

Answer: [SQL] SELECT T1.Participant_ID, T1.Participant_Type_Code, COUNT(*) FROM Participants AS T1 JOIN Participants_in_Events AS T2 ON T1.Participant_ID = T2.Participant_ID GROUP BY T1.Participant_ID [/SQL]


Question: What are all the the participant ids, type code and details?

Context: CREATE TABLE Participants (Participant_ID VARCHAR, Participant_Type_Code VARCHAR, Participant_Details VARCHAR)

Answer: [SQL] SELECT Participant_ID, Participant_Type_Code, Participant_Details FROM Participants [/SQL]


Question: How many participants belong to the type 'Organizer'?

Context: CREATE TABLE participants (participant_type_code VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM participants WHERE participant_type_code = 'Organizer' [/SQL]


Question: List the type of the services in alphabetical order.

Context: CREATE TABLE services (service_type_code VARCHAR)

Answer: [SQL] SELECT service_type_code FROM services ORDER BY service_type_code [/SQL]


Question: List the service id and details for the events.

Context: CREATE TABLE EVENTS (service_id VARCHAR, event_details VARCHAR)

Answer: [SQL] SELECT service_id, event_details FROM EVENTS [/SQL]


Question: How many events had participants whose details had the substring 'Dr.'

Context: CREATE TABLE participants (Participant_ID VARCHAR, participant_details VARCHAR); CREATE TABLE Participants_in_Events (Participant_ID VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM participants AS T1 JOIN Participants_in_Events AS T2 ON T1.Participant_ID = T2.Participant_ID WHERE T1.participant_details LIKE '%Dr.%' [/SQL]


Question: What is the most common participant type?

Answer: [SQL] SELECT participant_type_code FROM participants GROUP BY participant_type_code ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: Which service id and type has the least number of participants?

Context: CREATE TABLE Participants_in_Events (Participant_ID VARCHAR, Event_ID VARCHAR); CREATE TABLE services (Service_Type_Code VARCHAR, service_id VARCHAR); CREATE TABLE EVENTS (service_id VARCHAR, Event_ID VARCHAR); CREATE TABLE participants (Participant_ID VARCHAR)

Answer: [SQL] SELECT T3.service_id, T4.Service_Type_Code FROM participants AS T1 JOIN Participants_in_Events AS T2 ON T1.Participant_ID = T2.Participant_ID JOIN EVENTS AS T3 ON T2.Event_ID = T3.Event_ID JOIN services AS T4 ON T3.service_id = T4.service_id GROUP BY T3.service_id ORDER BY COUNT(*) LIMIT 1 [/SQL]


Question: What is the id of the event with the most participants?

Context: CREATE TABLE Participants_in_Events (Event_ID VARCHAR)

Answer: [SQL] SELECT Event_ID FROM Participants_in_Events GROUP BY Event_ID ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: Which events id does not have any participant with detail 'Kenyatta Kuhn'?

Context: CREATE TABLE Participants (Participant_ID VARCHAR); CREATE TABLE EVENTS (event_id VARCHAR, Participant_Details VARCHAR); CREATE TABLE Participants_in_Events (event_id VARCHAR, Participant_ID VARCHAR)

Answer: [SQL] SELECT event_id FROM EVENTS EXCEPT SELECT T1.event_id FROM Participants_in_Events AS T1 JOIN Participants AS T2 ON T1.Participant_ID = T2.Participant_ID WHERE Participant_Details = 'Kenyatta Kuhn' [/SQL]


Question: Which services type had both successful and failure event details?

Context: CREATE TABLE EVENTS (service_id VARCHAR, event_details VARCHAR); CREATE TABLE services (service_type_code VARCHAR, service_id VARCHAR)

Answer: [SQL] SELECT T1.service_type_code FROM services AS T1 JOIN EVENTS AS T2 ON T1.service_id = T2.service_id WHERE T2.event_details = 'Success' INTERSECT SELECT T1.service_type_code FROM services AS T1 JOIN EVENTS AS T2 ON T1.service_id = T2.service_id WHERE T2.event_details = 'Fail' [/SQL]


Question: How many events did not have any participants?

Context: CREATE TABLE EVENTS (event_id VARCHAR); CREATE TABLE Participants_in_Events (event_id VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM EVENTS WHERE NOT event_id IN (SELECT event_id FROM Participants_in_Events) [/SQL]


Question: What are all the distinct participant ids who attended any events?

Context: CREATE TABLE participants_in_Events (participant_id VARCHAR)

Answer: [SQL] SELECT COUNT(DISTINCT participant_id) FROM participants_in_Events [/SQL]


Question: What is the name of the race held most recently?

Context: CREATE TABLE races (name VARCHAR, date VARCHAR)

Answer: [SQL] SELECT name FROM races ORDER BY date DESC LIMIT 1 [/SQL]


Question: What is the name and date of the most recent race?

Answer: [SQL] SELECT name, date FROM races ORDER BY date DESC LIMIT 1 [/SQL]


Question: Find the names of all races held in 2017.

Context: CREATE TABLE races (name VARCHAR, YEAR VARCHAR)

Answer: [SQL] SELECT name FROM races WHERE YEAR = 2017 [/SQL]


Question: Find the distinct names of all races held between 2014 and 2017?

Context: CREATE TABLE races (name VARCHAR, YEAR INTEGER)

Answer: [SQL] SELECT DISTINCT name FROM races WHERE YEAR BETWEEN 2014 AND 2017 [/SQL]


Question: List the forename and surname of all distinct drivers who once had laptime less than 93000 milliseconds?

Context: CREATE TABLE drivers (forename VARCHAR, surname VARCHAR, driverid VARCHAR); CREATE TABLE laptimes (driverid VARCHAR, milliseconds INTEGER)

Answer: [SQL] SELECT DISTINCT T1.forename, T1.surname FROM drivers AS T1 JOIN laptimes AS T2 ON T1.driverid = T2.driverid WHERE T2.milliseconds < 93000 [/SQL]


Question: Find all the distinct id and nationality of drivers who have had laptime more than 100000 milliseconds?

Context: CREATE TABLE laptimes (driverid VARCHAR, milliseconds INTEGER); CREATE TABLE drivers (driverid VARCHAR, nationality VARCHAR)

Answer: [SQL] SELECT DISTINCT T1.driverid, T1.nationality FROM drivers AS T1 JOIN laptimes AS T2 ON T1.driverid = T2.driverid WHERE T2.milliseconds > 100000 [/SQL]


Question: What are the forename and surname of the driver who has the smallest laptime?

Context: CREATE TABLE laptimes (driverid VARCHAR, milliseconds VARCHAR); CREATE TABLE drivers (forename VARCHAR, surname VARCHAR, driverid VARCHAR)

Answer: [SQL] SELECT T1.forename, T1.surname FROM drivers AS T1 JOIN laptimes AS T2 ON T1.driverid = T2.driverid ORDER BY T2.milliseconds LIMIT 1 [/SQL]


Question: What is the id and family name of the driver who has the longest laptime?

Context: CREATE TABLE drivers (driverid VARCHAR, surname VARCHAR); CREATE TABLE laptimes (driverid VARCHAR, milliseconds VARCHAR)

Answer: [SQL] SELECT T1.driverid, T1.surname FROM drivers AS T1 JOIN laptimes AS T2 ON T1.driverid = T2.driverid ORDER BY T2.milliseconds DESC LIMIT 1 [/SQL]


Question: What is the id, forname and surname of the driver who had the first position in terms of laptime at least twice?

Context: CREATE TABLE drivers (driverid VARCHAR, forename VARCHAR, surname VARCHAR); CREATE TABLE laptimes (driverid VARCHAR)

Answer: [SQL] SELECT T1.driverid, T1.forename, T1.surname FROM drivers AS T1 JOIN laptimes AS T2 ON T1.driverid = T2.driverid WHERE POSITION = '1' GROUP BY T1.driverid HAVING COUNT(*) >= 2 [/SQL]


Question: How many drivers participated in the race Australian Grand Prix held in 2009?

Context: CREATE TABLE races (raceid VARCHAR, name VARCHAR); CREATE TABLE results (raceid VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM results AS T1 JOIN races AS T2 ON T1.raceid = T2.raceid WHERE T2.name = "Australian Grand Prix" AND YEAR = 2009 [/SQL]


Question: How many drivers did not participate in the races held in 2009?

Context: CREATE TABLE races (driverId VARCHAR, raceId VARCHAR, YEAR VARCHAR); CREATE TABLE results (driverId VARCHAR, raceId VARCHAR, YEAR VARCHAR)

Answer: [SQL] SELECT COUNT(DISTINCT driverId) FROM results WHERE NOT raceId IN (SELECT raceId FROM races WHERE YEAR <> 2009) [/SQL]


Question: Give me a list of names and years of races that had any driver whose forename is Lewis?

Context: CREATE TABLE drivers (driverid VARCHAR, forename VARCHAR); CREATE TABLE races (name VARCHAR, year VARCHAR, raceid VARCHAR); CREATE TABLE results (raceid VARCHAR, driverid VARCHAR)

Answer: [SQL] SELECT T2.name, T2.year FROM results AS T1 JOIN races AS T2 ON T1.raceid = T2.raceid JOIN drivers AS T3 ON T1.driverid = T3.driverid WHERE T3.forename = "Lewis" [/SQL]


Question: Find the forename and surname of drivers whose nationality is German?

Context: CREATE TABLE drivers (forename VARCHAR, surname VARCHAR, nationality VARCHAR)

Answer: [SQL] SELECT forename, surname FROM drivers WHERE nationality = "German" [/SQL]


Question: Find the id and forenames of drivers who participated both the races with name Australian Grand Prix and the races with name Chinese Grand Prix?

Context: CREATE TABLE races (raceid VARCHAR, name VARCHAR); CREATE TABLE results (driverid VARCHAR, raceid VARCHAR); CREATE TABLE drivers (forename VARCHAR, driverid VARCHAR)

Answer: [SQL] SELECT T2.driverid, T3.forename FROM races AS T1 JOIN results AS T2 ON T1.raceid = T2.raceid JOIN drivers AS T3 ON T2.driverid = T3.driverid WHERE T1.name = "Australian Grand Prix" INTERSECT SELECT T2.driverid, T3.forename FROM races AS T1 JOIN results AS T2 ON T1.raceid = T2.raceid JOIN drivers AS T3 ON T2.driverid = T3.driverid WHERE T1.name = "Chinese Grand Prix" [/SQL]


Question: What are the forenames and surnames of drivers who participated in the races named Australian Grand Prix but not the races named Chinese Grand Prix?

Context: CREATE TABLE races (raceid VARCHAR, name VARCHAR); CREATE TABLE drivers (forename VARCHAR, surname VARCHAR, driverid VARCHAR); CREATE TABLE results (raceid VARCHAR, driverid VARCHAR)

Answer: [SQL] SELECT T3.forename, T3.surname FROM races AS T1 JOIN results AS T2 ON T1.raceid = T2.raceid JOIN drivers AS T3 ON T2.driverid = T3.driverid WHERE T1.name = "Australian Grand Prix" EXCEPT SELECT T3.forename, T3.surname FROM races AS T1 JOIN results AS T2 ON T1.raceid = T2.raceid JOIN drivers AS T3 ON T2.driverid = T3.driverid WHERE T1.name = "Chinese Grand Prix" [/SQL]


Question: Find all the forenames of distinct drivers who was in position 1 as standing and won?

Context: CREATE TABLE driverstandings (driverid VARCHAR, position VARCHAR, wins VARCHAR); CREATE TABLE drivers (forename VARCHAR, driverid VARCHAR)

Answer: [SQL] SELECT DISTINCT T1.forename FROM drivers AS T1 JOIN driverstandings AS T2 ON T1.driverid = T2.driverid WHERE T2.position = 1 AND T2.wins = 1 [/SQL]


Question: Find all the forenames of distinct drivers who won in position 1 as driver standing and had more than 20 points?

Context: CREATE TABLE drivers (forename VARCHAR, driverid VARCHAR); CREATE TABLE driverstandings (driverid VARCHAR, points VARCHAR, position VARCHAR, wins VARCHAR)

Answer: [SQL] SELECT DISTINCT T1.forename FROM drivers AS T1 JOIN driverstandings AS T2 ON T1.driverid = T2.driverid WHERE T2.position = 1 AND T2.wins = 1 AND T2.points > 20 [/SQL]


Question: What are the numbers of constructors for different nationalities?

Context: CREATE TABLE constructors (nationality VARCHAR)

Answer: [SQL] SELECT COUNT(*), nationality FROM constructors GROUP BY nationality [/SQL]


Question: What are the numbers of races for each constructor id?

Context: CREATE TABLE constructorStandings (constructorid VARCHAR)

Answer: [SQL] SELECT COUNT(*), constructorid FROM constructorStandings GROUP BY constructorid [/SQL]


Question: What are the names of races that were held after 2017 and the circuits were in the country of Spain?

Context: CREATE TABLE races (name VARCHAR, circuitid VARCHAR, year VARCHAR); CREATE TABLE circuits (circuitid VARCHAR, country VARCHAR)

Answer: [SQL] SELECT T1.name FROM races AS T1 JOIN circuits AS T2 ON T1.circuitid = T2.circuitid WHERE T2.country = "Spain" AND T1.year > 2017 [/SQL]


Question: What are the unique names of races that held after 2000 and the circuits were in Spain?

Answer: [SQL] SELECT DISTINCT T1.name FROM races AS T1 JOIN circuits AS T2 ON T1.circuitid = T2.circuitid WHERE T2.country = "Spain" AND T1.year > 2000 [/SQL]


Question: Find the distinct driver id and the stop number of all drivers that have a shorter pit stop duration than some drivers in the race with id 841.

Context: CREATE TABLE pitstops (driverid VARCHAR, STOP VARCHAR, duration INTEGER, raceid VARCHAR)

Answer: [SQL] SELECT DISTINCT driverid, STOP FROM pitstops WHERE duration < (SELECT MAX(duration) FROM pitstops WHERE raceid = 841) [/SQL]


Question: Find the distinct driver id of all drivers that have a longer stop duration than some drivers in the race whose id is 841?

Answer: [SQL] SELECT DISTINCT driverid, STOP FROM pitstops WHERE duration > (SELECT MIN(duration) FROM pitstops WHERE raceid = 841) [/SQL]


Question: List the forenames of all distinct drivers in alphabetical order?

Context: CREATE TABLE drivers (forename VARCHAR)

Answer: [SQL] SELECT DISTINCT forename FROM drivers ORDER BY forename [/SQL]


Question: List the names of all distinct races in reversed  lexicographic order?

Context: CREATE TABLE races (name VARCHAR)

Answer: [SQL] SELECT DISTINCT name FROM races ORDER BY name DESC [/SQL]


Question: What are the names of races held between 2009 and 2011?

Context: CREATE TABLE races (name VARCHAR, YEAR INTEGER)

Answer: [SQL] SELECT name FROM races WHERE YEAR BETWEEN 2009 AND 2011 [/SQL]


Question: What are the names of races held after 12:00:00 or before 09:00:00?

Context: CREATE TABLE races (name VARCHAR, TIME VARCHAR)

Answer: [SQL] SELECT name FROM races WHERE TIME > "12:00:00" OR TIME < "09:00:00" [/SQL]


Question: What are the drivers' first, last names and id who had more than 8 pit stops or participated in more than 5 race results?

Context: CREATE TABLE drivers (forename VARCHAR, surname VARCHAR, driverid VARCHAR); CREATE TABLE results (driverid VARCHAR); CREATE TABLE pitstops (driverid VARCHAR)

Answer: [SQL] SELECT T1.forename, T1.surname, T1.driverid FROM drivers AS T1 JOIN pitstops AS T2 ON T1.driverid = T2.driverid GROUP BY T1.driverid HAVING COUNT(*) > 8 UNION SELECT T1.forename, T1.surname, T1.driverid FROM drivers AS T1 JOIN results AS T2 ON T1.driverid = T2.driverid GROUP BY T1.driverid HAVING COUNT(*) > 5 [/SQL]


Question: What are the drivers' last names and id who had 11 pit stops and participated in more than 5 race results?

Context: CREATE TABLE drivers (surname VARCHAR, driverid VARCHAR); CREATE TABLE results (driverid VARCHAR); CREATE TABLE pitstops (driverid VARCHAR)

Answer: [SQL] SELECT T1.surname, T1.driverid FROM drivers AS T1 JOIN pitstops AS T2 ON T1.driverid = T2.driverid GROUP BY T1.driverid HAVING COUNT(*) = 11 INTERSECT SELECT T1.surname, T1.driverid FROM drivers AS T1 JOIN results AS T2 ON T1.driverid = T2.driverid GROUP BY T1.driverid HAVING COUNT(*) > 5 [/SQL]


Question: What is the id and last name of the driver who participated in the most races after 2010?

Context: CREATE TABLE drivers (driverid VARCHAR, surname VARCHAR); CREATE TABLE races (raceid VARCHAR, year INTEGER); CREATE TABLE results (driverid VARCHAR, raceid VARCHAR)

Answer: [SQL] SELECT T1.driverid, T1.surname FROM drivers AS T1 JOIN results AS T2 ON T1.driverid = T2.driverid JOIN races AS T3 ON T2.raceid = T3.raceid WHERE T3.year > 2010 GROUP BY T1.driverid ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: What are the names of circuits that belong to UK or Malaysia?

Context: CREATE TABLE circuits (name VARCHAR, country VARCHAR)

Answer: [SQL] SELECT name FROM circuits WHERE country = "UK" OR country = "Malaysia" [/SQL]


Question: Find the id and location of circuits that belong to France or Belgium?

Context: CREATE TABLE circuits (circuitid VARCHAR, LOCATION VARCHAR, country VARCHAR)

Answer: [SQL] SELECT circuitid, LOCATION FROM circuits WHERE country = "France" OR country = "Belgium" [/SQL]


Question: Find the names of Japanese constructors that have once earned more than 5 points?

Context: CREATE TABLE constructorstandings (constructorid VARCHAR, points VARCHAR); CREATE TABLE constructors (name VARCHAR, constructorid VARCHAR, nationality VARCHAR)

Answer: [SQL] SELECT T1.name FROM constructors AS T1 JOIN constructorstandings AS T2 ON T1.constructorid = T2.constructorid WHERE T1.nationality = "Japanese" AND T2.points > 5 [/SQL]


Question: What is the average fastest lap speed in race named 'Monaco Grand Prix' in 2008 ?

Context: CREATE TABLE results (fastestlapspeed INTEGER, raceid VARCHAR); CREATE TABLE races (raceid VARCHAR, year VARCHAR, name VARCHAR)

Answer: [SQL] SELECT AVG(T2.fastestlapspeed) FROM races AS T1 JOIN results AS T2 ON T1.raceid = T2.raceid WHERE T1.year = 2008 AND T1.name = "Monaco Grand Prix" [/SQL]


Question: What is the maximum fastest lap speed in race named 'Monaco Grand Prix' in 2008 ?

Answer: [SQL] SELECT MAX(T2.fastestlapspeed) FROM races AS T1 JOIN results AS T2 ON T1.raceid = T2.raceid WHERE T1.year = 2008 AND T1.name = "Monaco Grand Prix" [/SQL]


Question: What are the maximum fastest lap speed in races held after 2004 grouped by race name and ordered by year?

Context: CREATE TABLE results (fastestlapspeed INTEGER, raceid VARCHAR); CREATE TABLE races (name VARCHAR, year INTEGER, raceid VARCHAR)

Answer: [SQL] SELECT MAX(T2.fastestlapspeed), T1.name, T1.year FROM races AS T1 JOIN results AS T2 ON T1.raceid = T2.raceid WHERE T1.year > 2014 GROUP BY T1.name ORDER BY T1.year [/SQL]


Question: What are the average fastest lap speed in races held after 2004 grouped by race name and ordered by year?

Answer: [SQL] SELECT AVG(T2.fastestlapspeed), T1.name, T1.year FROM races AS T1 JOIN results AS T2 ON T1.raceid = T2.raceid WHERE T1.year > 2014 GROUP BY T1.name ORDER BY T1.year [/SQL]


Question: Find the id, forename and number of races of all drivers who have at least participated in two races?

Context: CREATE TABLE drivers (driverid VARCHAR, forename VARCHAR); CREATE TABLE races (raceid VARCHAR); CREATE TABLE results (driverid VARCHAR, raceid VARCHAR)

Answer: [SQL] SELECT T1.driverid, T1.forename, COUNT(*) FROM drivers AS T1 JOIN results AS T2 ON T1.driverid = T2.driverid JOIN races AS T3 ON T2.raceid = T3.raceid GROUP BY T1.driverid HAVING COUNT(*) >= 2 [/SQL]


Question: Find the driver id and number of races of all drivers who have at most participated in 30 races?

Context: CREATE TABLE races (raceid VARCHAR); CREATE TABLE results (driverid VARCHAR, raceid VARCHAR); CREATE TABLE drivers (driverid VARCHAR)

Answer: [SQL] SELECT T1.driverid, COUNT(*) FROM drivers AS T1 JOIN results AS T2 ON T1.driverid = T2.driverid JOIN races AS T3 ON T2.raceid = T3.raceid GROUP BY T1.driverid HAVING COUNT(*) <= 30 [/SQL]


Question: Find the id and surname of the driver who participated the most number of races?

Context: CREATE TABLE drivers (driverid VARCHAR, surname VARCHAR); CREATE TABLE races (raceid VARCHAR); CREATE TABLE results (driverid VARCHAR, raceid VARCHAR)

Answer: [SQL] SELECT T1.driverid, T1.surname FROM drivers AS T1 JOIN results AS T2 ON T1.driverid = T2.driverid JOIN races AS T3 ON T2.raceid = T3.raceid GROUP BY T1.driverid ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: How many technicians are there?

Context: CREATE TABLE technician (Id VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM technician [/SQL]


Question: List the names of technicians in ascending order of age.

Context: CREATE TABLE technician (Name VARCHAR, Age VARCHAR)

Answer: [SQL] SELECT Name FROM technician ORDER BY Age [/SQL]


Question: What are the team and starting year of technicians?

Context: CREATE TABLE technician (Team VARCHAR, Starting_Year VARCHAR)

Answer: [SQL] SELECT Team, Starting_Year FROM technician [/SQL]