Question: Show the name and population of the country that has the highest roller coaster.

Context: CREATE TABLE roller_coaster (Country_ID VARCHAR, Height VARCHAR); CREATE TABLE country (Name VARCHAR, population VARCHAR, Country_ID VARCHAR)

SELECT T1.Name, T1.population FROM country AS T1 JOIN roller_coaster AS T2 ON T1.Country_ID = T2.Country_ID ORDER BY T2.Height DESC LIMIT 1


Question: Show the names of countries and the average speed of roller coasters from each country.

Context: CREATE TABLE roller_coaster (Speed INTEGER, Country_ID VARCHAR); CREATE TABLE country (Name VARCHAR, Country_ID VARCHAR)

SELECT T1.Name, AVG(T2.Speed) FROM country AS T1 JOIN roller_coaster AS T2 ON T1.Country_ID = T2.Country_ID GROUP BY T1.Name


Question: How many countries do not have an roller coaster longer than 3000?

Context: CREATE TABLE country (country_id VARCHAR, LENGTH INTEGER); CREATE TABLE roller_coaster (country_id VARCHAR, LENGTH INTEGER)

SELECT COUNT(*) FROM country WHERE NOT country_id IN (SELECT country_id FROM roller_coaster WHERE LENGTH > 3000)


Question: What are the country names, area and population which has both roller coasters with speed higher

Context: CREATE TABLE country (name VARCHAR, area VARCHAR, population VARCHAR, Country_ID VARCHAR); CREATE TABLE roller_coaster (Country_ID VARCHAR, speed INTEGER)

SELECT T1.name, T1.area, T1.population FROM country AS T1 JOIN roller_coaster AS T2 ON T1.Country_ID = T2.Country_ID WHERE T2.speed > 60 INTERSECT SELECT T1.name, T1.area, T1.population FROM country AS T1 JOIN roller_coaster AS T2 ON T1.Country_ID = T2.Country_ID WHERE T2.speed < 55


Question: How many different captain ranks are there?

Context: CREATE TABLE captain (rank VARCHAR)

SELECT COUNT(DISTINCT rank) FROM captain


Question: How many captains are in each rank?

Context: CREATE TABLE captain (rank VARCHAR)

SELECT COUNT(*), rank FROM captain GROUP BY rank


Question: How many captains with younger than 50 are in each rank?

Context: CREATE TABLE captain (rank VARCHAR, age INTEGER)

SELECT COUNT(*), rank FROM captain WHERE age < 50 GROUP BY rank


Question: Sort all captain names by their ages from old to young.

Context: CREATE TABLE captain (name VARCHAR, age VARCHAR)

SELECT name FROM captain ORDER BY age DESC


Question: Find the name, class and rank of all captains.

Context: CREATE TABLE captain (name VARCHAR, CLASS VARCHAR, rank VARCHAR)


Question: Which rank is the most common among captains?

Context: CREATE TABLE captain (rank VARCHAR)

SELECT rank FROM captain GROUP BY rank ORDER BY COUNT(*) DESC LIMIT 1


Question: Which classes have more than two captains?

Context: CREATE TABLE captain (CLASS VARCHAR)

SELECT CLASS FROM captain GROUP BY CLASS HAVING COUNT(*) > 2


Question: Find the name of captains whose rank are either Midshipman or Lieutenant.

Context: CREATE TABLE captain (name VARCHAR, rank VARCHAR)

SELECT name FROM captain WHERE rank = 'Midshipman' OR rank = 'Lieutenant'


Question: What are the average and minimum age of captains in different class?

Context: CREATE TABLE captain (CLASS VARCHAR, age INTEGER)

SELECT AVG(age), MIN(age), CLASS FROM captain GROUP BY CLASS


Question: Find the captain rank that has some captains in both Cutter and Armed schooner classes.

Context: CREATE TABLE captain (rank VARCHAR, CLASS VARCHAR)

SELECT rank FROM captain WHERE CLASS = 'Cutter' INTERSECT SELECT rank FROM captain WHERE CLASS = 'Armed schooner'


Question: Find the captain rank that has no captain in Third-rate ship of the line class.

SELECT rank FROM captain EXCEPT SELECT rank FROM captain WHERE CLASS = 'Third-rate ship of the line'


Question: What is the name of the youngest captain?

SELECT name FROM captain ORDER BY age LIMIT 1


Question: Find the name, type, and flag of the ship that is built in the most recent year.

Context: CREATE TABLE ship (name VARCHAR, TYPE VARCHAR, flag VARCHAR, built_year VARCHAR)

SELECT name, TYPE, flag FROM ship ORDER BY built_year DESC LIMIT 1


Question: Group by ships by flag, and return number of ships that have each flag.

Context: CREATE TABLE ship (flag VARCHAR)

SELECT COUNT(*), flag FROM ship GROUP BY flag


Question: Which flag is most widely used among all ships?

Context: CREATE TABLE ship (flag VARCHAR)

SELECT flag FROM ship GROUP BY flag ORDER BY COUNT(*) DESC LIMIT 1


Question: List all ship names in the order of built year and class.

Context: CREATE TABLE ship (name VARCHAR, built_year VARCHAR, CLASS VARCHAR)

SELECT name FROM ship ORDER BY built_year, CLASS


Question: Find the ship type that are used by both ships with Panama and Malta flags.

Context: CREATE TABLE ship (TYPE VARCHAR, flag VARCHAR)

SELECT TYPE FROM ship WHERE flag = 'Panama' INTERSECT SELECT TYPE FROM ship WHERE flag = 'Malta'


Question: In which year were most of ships built?

Context: CREATE TABLE ship (built_year VARCHAR)

SELECT built_year FROM ship GROUP BY built_year ORDER BY COUNT(*) DESC LIMIT 1


Question: Find the name of the ships that have more than one captain.

Context: CREATE TABLE captain (ship_id VARCHAR); CREATE TABLE ship (name VARCHAR, ship_id VARCHAR)

SELECT t1.name FROM ship AS t1 JOIN captain AS t2 ON t1.ship_id = t2.ship_id GROUP BY t2.ship_id HAVING COUNT(*) > 1


Question: what are the names and classes of the ships that do not have any captain yet?

Context: CREATE TABLE ship (name VARCHAR, CLASS VARCHAR, ship_id VARCHAR); CREATE TABLE captain (name VARCHAR, CLASS VARCHAR, ship_id VARCHAR)

SELECT name, CLASS FROM ship WHERE NOT ship_id IN (SELECT ship_id FROM captain)


Question: Find the name of the ship that is steered by the youngest captain.

Context: CREATE TABLE ship (name VARCHAR, ship_id VARCHAR); CREATE TABLE captain (ship_id VARCHAR, age VARCHAR)

SELECT t1.name FROM ship AS t1 JOIN captain AS t2 ON t1.ship_id = t2.ship_id ORDER BY t2.age LIMIT 1


Question: Find the name and flag of ships that are not steered by any captain with Midshipman rank.

Context: CREATE TABLE captain (name VARCHAR, flag VARCHAR, ship_id VARCHAR, rank VARCHAR); CREATE TABLE ship (name VARCHAR, flag VARCHAR, ship_id VARCHAR, rank VARCHAR)

SELECT name, flag FROM ship WHERE NOT ship_id IN (SELECT ship_id FROM captain WHERE rank = 'Midshipman')


Question: Find the name of the ships that are steered by both a captain with Midshipman rank and a captain with Lieutenant rank.

Context: CREATE TABLE ship (name VARCHAR, ship_id VARCHAR); CREATE TABLE captain (ship_id VARCHAR, rank VARCHAR)

SELECT t1.name FROM ship AS t1 JOIN captain AS t2 ON t1.ship_id = t2.ship_id WHERE t2.rank = 'Midshipman' INTERSECT SELECT t1.name FROM ship AS t1 JOIN captain AS t2 ON t1.ship_id = t2.ship_id WHERE t2.rank = 'Lieutenant'


Question: What is id of the city that hosted events in the most recent year?

Context: CREATE TABLE hosting_city (host_city VARCHAR, YEAR VARCHAR)

SELECT host_city FROM hosting_city ORDER BY YEAR DESC LIMIT 1


Question: Find the match ids of the cities that hosted competition "1994 FIFA World Cup qualification"?

Context: CREATE TABLE MATCH (match_id VARCHAR, competition VARCHAR)

SELECT match_id FROM MATCH WHERE competition = "1994 FIFA World Cup qualification"


Question: Find the cities which were once a host city after 2010?

Context: CREATE TABLE city (city VARCHAR, city_id VARCHAR); CREATE TABLE hosting_city (host_city VARCHAR, year INTEGER)

SELECT T1.city FROM city AS T1 JOIN hosting_city AS T2 ON T1.city_id = T2.host_city WHERE T2.year > 2010


Question: Which city has hosted the most events?

Context: CREATE TABLE city (city VARCHAR, city_id VARCHAR); CREATE TABLE hosting_city (host_city VARCHAR)

SELECT T1.city FROM city AS T1 JOIN hosting_city AS T2 ON T1.city_id = T2.host_city GROUP BY T2.host_city ORDER BY COUNT(*) DESC LIMIT 1


Question: What is the venue of the competition "1994 FIFA World Cup qualification" hosted by "Nanjing ( Jiangsu )"?

Context: CREATE TABLE city (city_id VARCHAR, city VARCHAR); CREATE TABLE MATCH (venue VARCHAR, match_id VARCHAR, competition VARCHAR); CREATE TABLE hosting_city (host_city VARCHAR, match_id VARCHAR)

SELECT T3.venue FROM city AS T1 JOIN hosting_city AS T2 ON T1.city_id = T2.host_city JOIN MATCH AS T3 ON T2.match_id = T3.match_id WHERE T1.city = "Nanjing ( Jiangsu )" AND T3.competition = "1994 FIFA World Cup qualification"


Question: Give me the temperature of Shanghai in January.

Context: CREATE TABLE city (city_id VARCHAR, city VARCHAR); CREATE TABLE temperature (Jan VARCHAR, city_id VARCHAR)

SELECT T2.Jan FROM city AS T1 JOIN temperature AS T2 ON T1.city_id = T2.city_id WHERE T1.city = "Shanghai"


Question: What is the host year of city "Taizhou ( Zhejiang )"?

Context: CREATE TABLE city (city_id VARCHAR, city VARCHAR); CREATE TABLE hosting_city (year VARCHAR, host_city VARCHAR)

SELECT T2.year FROM city AS T1 JOIN hosting_city AS T2 ON T1.city_id = T2.host_city WHERE T1.city = "Taizhou ( Zhejiang )"


Question: Which three cities have the largest regional population?

Context: CREATE TABLE city (city VARCHAR, regional_population VARCHAR)

SELECT city FROM city ORDER BY regional_population DESC LIMIT 3


Question: Which city has the lowest GDP? Please list the city name and its GDP.

Context: CREATE TABLE city (city VARCHAR, GDP VARCHAR)

SELECT city, GDP FROM city ORDER BY GDP LIMIT 1


Question: Which city has the highest temperature in February?

Context: CREATE TABLE city (city VARCHAR, city_id VARCHAR); CREATE TABLE temperature (city_id VARCHAR, Feb VARCHAR)

SELECT T1.city FROM city AS T1 JOIN temperature AS T2 ON T1.city_id = T2.city_id ORDER BY T2.Feb DESC LIMIT 1


Question: Give me a list of cities whose temperature in March is lower than that in July or higher than that in Oct?

Context: CREATE TABLE city (city VARCHAR, city_id VARCHAR); CREATE TABLE temperature (city_id VARCHAR, Mar VARCHAR, Jul VARCHAR, Oct VARCHAR)

SELECT T1.city FROM city AS T1 JOIN temperature AS T2 ON T1.city_id = T2.city_id WHERE T2.Mar < T2.Jul OR T2.Mar > T2.Oct


Question: Give me a list of cities whose temperature in Mar is lower than that in July and which have also served as host cities?

Context: CREATE TABLE city (city VARCHAR, city_id VARCHAR); CREATE TABLE hosting_city (host_city VARCHAR); CREATE TABLE temperature (city_id VARCHAR, Mar INTEGER, Jul VARCHAR)

SELECT T1.city FROM city AS T1 JOIN temperature AS T2 ON T1.city_id = T2.city_id WHERE T2.Mar < T2.Jul INTERSECT SELECT T3.city FROM city AS T3 JOIN hosting_city AS T4 ON T3.city_id = T4.host_city


Question: Give me a list of cities whose temperature in Mar is lower than that in Dec and which have never been host cities.

Context: CREATE TABLE city (city VARCHAR, city_id VARCHAR); CREATE TABLE hosting_city (host_city VARCHAR); CREATE TABLE temperature (city_id VARCHAR, Mar INTEGER, Dec VARCHAR)

SELECT T1.city FROM city AS T1 JOIN temperature AS T2 ON T1.city_id = T2.city_id WHERE T2.Mar < T2.Dec EXCEPT SELECT T3.city FROM city AS T3 JOIN hosting_city AS T4 ON T3.city_id = T4.host_city


Question: Give me a list of cities whose temperature in Feb is higher than that in Jun or cities that were once host cities?

Context: CREATE TABLE city (city VARCHAR, city_id VARCHAR); CREATE TABLE hosting_city (host_city VARCHAR); CREATE TABLE temperature (city_id VARCHAR, Feb INTEGER, Jun VARCHAR)

SELECT T1.city FROM city AS T1 JOIN temperature AS T2 ON T1.city_id = T2.city_id WHERE T2.Feb > T2.Jun UNION SELECT T3.city FROM city AS T3 JOIN hosting_city AS T4 ON T3.city_id = T4.host_city


Question: Please give me a list of cities whose regional population is over 10000000.

Context: CREATE TABLE city (city VARCHAR, regional_population INTEGER)

SELECT city FROM city WHERE regional_population > 10000000


Question: Please give me a list of cities whose regional population is over 8000000 or under 5000000.

SELECT city FROM city WHERE regional_population > 10000000 UNION SELECT city FROM city WHERE regional_population < 5000000


Question: Find the number of matches in different competitions.

Context: CREATE TABLE MATCH (Competition VARCHAR)

SELECT COUNT(*), Competition FROM MATCH GROUP BY Competition


Question: List venues of all matches in the order of their dates starting from the most recent one.

Context: CREATE TABLE MATCH (venue VARCHAR, date VARCHAR)

SELECT venue FROM MATCH ORDER BY date DESC


Question: what is the GDP of the city with the largest population.

Context: CREATE TABLE city (gdp VARCHAR, Regional_Population VARCHAR)

SELECT gdp FROM city ORDER BY Regional_Population DESC LIMIT 1


Question: What are the GDP and population of the city that already served as a host more than once?

Context: CREATE TABLE hosting_city (host_city VARCHAR); CREATE TABLE city (city_id VARCHAR)

SELECT t1.gdp, t1.Regional_Population FROM city AS T1 JOIN hosting_city AS T2 ON T1.city_id = T2.host_city GROUP BY t2.Host_City HAVING COUNT(*) > 1


Question: List every individual's first name, middle name and last name in alphabetical order by last name.

Context: CREATE TABLE individuals (individual_first_name VARCHAR, individual_middle_name VARCHAR, individual_last_name VARCHAR)

SELECT individual_first_name, individual_middle_name, individual_last_name FROM individuals ORDER BY individual_last_name


Question: List all the types of forms.

Context: CREATE TABLE forms (form_type_code VARCHAR)

SELECT DISTINCT form_type_code FROM forms


Question: Find the name of the most popular party form.

Context: CREATE TABLE party_forms (form_id VARCHAR); CREATE TABLE forms (form_name VARCHAR, form_id VARCHAR)

SELECT t1.form_name FROM forms AS t1 JOIN party_forms AS t2 ON t1.form_id = t2.form_id GROUP BY t2.form_id ORDER BY COUNT(*) DESC LIMIT 1


Question: Find the payment method and phone of the party with email "enrico09@example.com".

Context: CREATE TABLE parties (payment_method_code VARCHAR, party_phone VARCHAR, party_email VARCHAR)

SELECT payment_method_code, party_phone FROM parties WHERE party_email = "enrico09@example.com"


Question: Find the emails of parties with the most popular party form.

Context: CREATE TABLE party_forms (form_id VARCHAR); CREATE TABLE parties (party_email VARCHAR, party_id VARCHAR); CREATE TABLE party_forms (party_id VARCHAR, form_id VARCHAR)

SELECT t1.party_email FROM parties AS t1 JOIN party_forms AS t2 ON t1.party_id = t2.party_id WHERE t2.form_id = (SELECT form_id FROM party_forms GROUP BY form_id ORDER BY COUNT(*) DESC LIMIT 1)


Question: List all the name of organizations in order of the date formed.

Context: CREATE TABLE organizations (organization_name VARCHAR, date_formed VARCHAR)

SELECT organization_name FROM organizations ORDER BY date_formed


Question: Find the name of the youngest organization.

SELECT organization_name FROM organizations ORDER BY date_formed DESC LIMIT 1


Question: Find the last name of the latest contact individual of the organization "Labour Party".

Context: CREATE TABLE organizations (organization_id VARCHAR, organization_name VARCHAR); CREATE TABLE individuals (individual_last_name VARCHAR, individual_id VARCHAR); CREATE TABLE organization_contact_individuals (organization_id VARCHAR, individual_id VARCHAR, date_contact_to VARCHAR)

SELECT t3.individual_last_name FROM organizations AS t1 JOIN organization_contact_individuals AS t2 ON t1.organization_id = t2.organization_id JOIN individuals AS t3 ON t2.individual_id = t3.individual_id WHERE t1.organization_name = "Labour Party" ORDER BY t2.date_contact_to DESC LIMIT 1


Question: Find the last name of the first ever contact person of the organization with the highest UK Vat number.

Context: CREATE TABLE organizations (uk_vat_number INTEGER); CREATE TABLE individuals (individual_last_name VARCHAR, individual_id VARCHAR); CREATE TABLE organizations (organization_id VARCHAR, uk_vat_number INTEGER); CREATE TABLE organization_contact_individuals (organization_id VARCHAR, individual_id VARCHAR, date_contact_to VARCHAR)

SELECT t3.individual_last_name FROM organizations AS t1 JOIN organization_contact_individuals AS t2 ON t1.organization_id = t2.organization_id JOIN individuals AS t3 ON t2.individual_id = t3.individual_id WHERE t1.uk_vat_number = (SELECT MAX(uk_vat_number) FROM organizations) ORDER BY t2.date_contact_to LIMIT 1


Question: Find name of the services that has never been used.

Context: CREATE TABLE services (service_name VARCHAR); CREATE TABLE party_services (service_id VARCHAR); CREATE TABLE services (service_name VARCHAR, service_id VARCHAR)

SELECT service_name FROM services EXCEPT SELECT t1.service_name FROM services AS t1 JOIN party_services AS t2 ON t1.service_id = t2.service_id


Question: Find the name of all the cities and states.

Context: CREATE TABLE addresses (town_city VARCHAR, state_province_county VARCHAR)

SELECT town_city FROM addresses UNION SELECT state_province_county FROM addresses


Question: How many cities are there in state "Colorado"?

Context: CREATE TABLE addresses (state_province_county VARCHAR)

SELECT COUNT(*) FROM addresses WHERE state_province_county = "Colorado"


Question: Find the payment method code used by more than 3 parties.

Context: CREATE TABLE parties (payment_method_code VARCHAR)

SELECT payment_method_code FROM parties GROUP BY payment_method_code HAVING COUNT(*) > 3


Question: Find the name of organizations whose names contain "Party".

Context: CREATE TABLE organizations (organization_name VARCHAR)

SELECT organization_name FROM organizations WHERE organization_name LIKE "%Party%"


Question: How many distinct payment methods are used by parties?

SELECT COUNT(DISTINCT payment_method_code) FROM parties


Question: Which is the email of the party that has used the services the most number of times?

Context: CREATE TABLE parties (party_email VARCHAR, party_id VARCHAR); CREATE TABLE party_services (customer_id VARCHAR)

SELECT t1.party_email FROM parties AS t1 JOIN party_services AS t2 ON t1.party_id = t2.customer_id GROUP BY t1.party_email ORDER BY COUNT(*) DESC LIMIT 1


Question: Which state can address "6862 Kaitlyn Knolls" possibly be in?

Context: CREATE TABLE addresses (state_province_county VARCHAR, line_1_number_building VARCHAR)

SELECT state_province_county FROM addresses WHERE line_1_number_building LIKE "%6862 Kaitlyn Knolls%"


Question: What is the name of organization that has the greatest number of contact individuals?

Context: CREATE TABLE organization_contact_individuals (organization_id VARCHAR); CREATE TABLE organizations (organization_name VARCHAR, organization_id VARCHAR)

SELECT t1.organization_name FROM organizations AS t1 JOIN organization_contact_individuals AS t2 ON t1.organization_id = t2.organization_id GROUP BY t1.organization_name ORDER BY COUNT(*) DESC LIMIT 1


Question: Find the last name of the individuals that have been contact individuals of an organization.

Context: CREATE TABLE individuals (individual_last_name VARCHAR, individual_id VARCHAR); CREATE TABLE organization_contact_individuals (individual_id VARCHAR)

SELECT DISTINCT t1.individual_last_name FROM individuals AS t1 JOIN organization_contact_individuals AS t2 ON t1.individual_id = t2.individual_id


Question: How many drivers are there?

Context: CREATE TABLE driver (Id VARCHAR)


Question: Show the name, home city, and age for all drivers.

Context: CREATE TABLE driver (name VARCHAR, home_city VARCHAR, age VARCHAR)


Question: Show the party and the number of drivers in each party.

Context: CREATE TABLE driver (party VARCHAR)

SELECT party, COUNT(*) FROM driver GROUP BY party


Question: Show the name of drivers in descending order of age.

Context: CREATE TABLE driver (name VARCHAR, age VARCHAR)

SELECT name FROM driver ORDER BY age DESC


Question: Show all different home cities.

Context: CREATE TABLE driver (home_city VARCHAR)


Question: Show the home city with the most number of drivers.

Context: CREATE TABLE driver (home_city VARCHAR)

SELECT home_city FROM driver GROUP BY home_city ORDER BY COUNT(*) DESC LIMIT 1


Question: Show the party with drivers from Hartford and drivers older than 40.

Context: CREATE TABLE driver (party VARCHAR, home_city VARCHAR, age VARCHAR)

SELECT party FROM driver WHERE home_city = 'Hartford' AND age > 40


Question: Show home city where at least two drivers older than 40 are from.

Context: CREATE TABLE driver (home_city VARCHAR, age INTEGER)

SELECT home_city FROM driver WHERE age > 40 GROUP BY home_city HAVING COUNT(*) >= 2


Question: Show all home cities except for those having a driver older than 40.

SELECT home_city FROM driver EXCEPT SELECT home_city FROM driver WHERE age > 40


Question: Show the names of the drivers without a school bus.

Context: CREATE TABLE school_bus (name VARCHAR, driver_id VARCHAR); CREATE TABLE driver (name VARCHAR, driver_id VARCHAR)

SELECT name FROM driver WHERE NOT driver_id IN (SELECT driver_id FROM school_bus)


Question: Show the types of schools that have two schools.

Context: CREATE TABLE school (TYPE VARCHAR)

SELECT TYPE FROM school GROUP BY TYPE HAVING COUNT(*) = 2


Question: Show the school name and driver name for all school buses.

Context: CREATE TABLE school (school VARCHAR, school_id VARCHAR); CREATE TABLE school_bus (school_id VARCHAR, driver_id VARCHAR); CREATE TABLE driver (name VARCHAR, driver_id VARCHAR)

SELECT T2.school, T3.name FROM school_bus AS T1 JOIN school AS T2 ON T1.school_id = T2.school_id JOIN driver AS T3 ON T1.driver_id = T3.driver_id


Question: What is the maximum, minimum and average years spent working on a school bus?

Context: CREATE TABLE school_bus (years_working INTEGER)

SELECT MAX(years_working), MIN(years_working), AVG(years_working) FROM school_bus


Question: Show the school name and type for schools without a school bus.

Context: CREATE TABLE school_bus (school VARCHAR, TYPE VARCHAR, school_id VARCHAR); CREATE TABLE school (school VARCHAR, TYPE VARCHAR, school_id VARCHAR)

SELECT school, TYPE FROM school WHERE NOT school_id IN (SELECT school_id FROM school_bus)


Question: Show the type of school and the number of buses for each type.

Context: CREATE TABLE school (type VARCHAR, school_id VARCHAR); CREATE TABLE school_bus (school_id VARCHAR)

SELECT T2.type, COUNT(*) FROM school_bus AS T1 JOIN school AS T2 ON T1.school_id = T2.school_id GROUP BY T2.type


Question: How many drivers are from Hartford city or younger than 40?

Context: CREATE TABLE driver (home_city VARCHAR, age VARCHAR)

SELECT COUNT(*) FROM driver WHERE home_city = 'Hartford' OR age < 40


Question: List names for drivers from Hartford city and younger than 40.

SELECT name FROM driver WHERE home_city = 'Hartford' AND age < 40


Question: find the name of driver who is driving the school bus with the longest working history.

Context: CREATE TABLE school_bus (driver_id VARCHAR); CREATE TABLE driver (name VARCHAR, driver_id VARCHAR)

SELECT t1.name FROM driver AS t1 JOIN school_bus AS t2 ON t1.driver_id = t2.driver_id ORDER BY years_working DESC LIMIT 1


Question: How many flights have a velocity larger than 200?

Context: CREATE TABLE flight (velocity INTEGER)

SELECT COUNT(*) FROM flight WHERE velocity > 200


Question: List the vehicle flight number, date and pilot of all the flights, ordered by altitude.

Context: CREATE TABLE flight (vehicle_flight_number VARCHAR, date VARCHAR, pilot VARCHAR, altitude VARCHAR)

SELECT vehicle_flight_number, date, pilot FROM flight ORDER BY altitude


Question: List the id, country, city and name of the airports ordered alphabetically by the name.

Context: CREATE TABLE airport (id VARCHAR, country VARCHAR, city VARCHAR, name VARCHAR)

SELECT id, country, city, name FROM airport ORDER BY name


Question: What is maximum group equity shareholding of the companies?

Context: CREATE TABLE operate_company (group_equity_shareholding INTEGER)

SELECT MAX(group_equity_shareholding) FROM operate_company


Question: What is the velocity of the pilot named 'Thompson'?

Context: CREATE TABLE flight (velocity INTEGER, pilot VARCHAR)

SELECT AVG(velocity) FROM flight WHERE pilot = 'Thompson'


Question: What are the names and types of the companies that have ever operated a flight?

Context: CREATE TABLE operate_company (name VARCHAR, type VARCHAR, id VARCHAR); CREATE TABLE flight (Id VARCHAR)

SELECT T1.name, T1.type FROM operate_company AS T1 JOIN flight AS t2 ON T1.id = T2.company_id


Question: What are the names of the airports which are not in the country 'Iceland'?

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

SELECT name FROM airport WHERE country <> 'Iceland'


Question: What are the distinct types of the companies that have operated any flights with velocity less than 200?

Context: CREATE TABLE flight (Id VARCHAR); CREATE TABLE operate_company (type VARCHAR, id VARCHAR)

SELECT DISTINCT T1.type FROM operate_company AS T1 JOIN flight AS t2 ON T1.id = T2.company_id WHERE T2.velocity < 200


Question: What are the ids and names of the companies that operated more than one flight?

Context: CREATE TABLE flight (Id VARCHAR); CREATE TABLE operate_company (id VARCHAR, name VARCHAR)

SELECT T1.id, T1.name FROM operate_company AS T1 JOIN flight AS t2 ON T1.id = T2.company_id GROUP BY T1.id HAVING COUNT(*) > 1


Question: What is the id, name and IATA code of the airport that had most number of flights?

Context: CREATE TABLE airport (id VARCHAR, name VARCHAR, IATA VARCHAR); CREATE TABLE flight (id VARCHAR, airport_id VARCHAR)

SELECT T1.id, T1.name, T1.IATA FROM airport AS T1 JOIN flight AS T2 ON T1.id = T2.airport_id GROUP BY T2.id ORDER BY COUNT(*) DESC LIMIT 1


Question: What are the different pilot names who had piloted a flight in the country 'United States' or in the airport named 'Billund Airport'?

Context: CREATE TABLE airport (id VARCHAR, country VARCHAR, name VARCHAR); CREATE TABLE flight (pilot VARCHAR, airport_id VARCHAR)

SELECT DISTINCT T2.pilot FROM airport AS T1 JOIN flight AS T2 ON T1.id = T2.airport_id WHERE T1.country = 'United States' OR T1.name = 'Billund Airport'


Question: What is the most common company type, and how many are there?

Context: CREATE TABLE operate_company (TYPE VARCHAR)

SELECT TYPE, COUNT(*) FROM operate_company GROUP BY TYPE ORDER BY COUNT(*) DESC LIMIT 1


Question: How many airports haven't the pilot 'Thompson' driven an aircraft?

Context: CREATE TABLE airport (id VARCHAR, airport_id VARCHAR, pilot VARCHAR); CREATE TABLE flight (id VARCHAR, airport_id VARCHAR, pilot VARCHAR)

SELECT COUNT(*) FROM airport WHERE NOT id IN (SELECT airport_id FROM flight WHERE pilot = 'Thompson')


Question: List the name of the pilots who have flied for both a company that mainly provide 'Cargo' services and a company that runs 'Catering services' activities.

Context: CREATE TABLE operate_company (id VARCHAR, principal_activities VARCHAR); CREATE TABLE flight (Id VARCHAR)

SELECT T2.pilot FROM operate_company AS T1 JOIN flight AS t2 ON T1.id = T2.company_id WHERE T1.principal_activities = 'Cargo' INTERSECT SELECT T2.pilot FROM operate_company AS T1 JOIN flight AS t2 ON T1.id = T2.company_id WHERE T1.principal_activities = 'Catering services'


Question: Which of the airport names contains the word 'international'?

Context: CREATE TABLE airport (name VARCHAR)

SELECT name FROM airport WHERE name LIKE '%international%'


Question: How many companies operates airlines in each airport?

Context: CREATE TABLE airport (id VARCHAR); CREATE TABLE flight (Id VARCHAR); CREATE TABLE operate_company (id VARCHAR)

SELECT T3.id, COUNT(*) FROM operate_company AS T1 JOIN flight AS t2 ON T1.id = T2.company_id JOIN airport AS T3 ON T2.airport_id = T3.id GROUP BY T3.id


Question: how many airports are there in each country?

Context: CREATE TABLE airport (country VARCHAR)

SELECT COUNT(*), country FROM airport GROUP BY country


Question: which countries have more than 2 airports?

Context: CREATE TABLE airport (country VARCHAR)

SELECT country FROM airport GROUP BY country HAVING COUNT(*) > 2


Question: which pilot is in charge of the most number of flights?

Context: CREATE TABLE flight (pilot VARCHAR)

SELECT pilot FROM flight GROUP BY pilot ORDER BY COUNT(*) DESC LIMIT 1


Question: Show all account ids and account details.

Context: CREATE TABLE Accounts (account_id VARCHAR, account_details VARCHAR)

SELECT account_id, account_details FROM Accounts


Question: How many statements do we have?

Context: CREATE TABLE Statements (Id VARCHAR)


Question: List all statement ids and statement details.

Context: CREATE TABLE Statements (STATEMENT_ID VARCHAR, statement_details VARCHAR)

SELECT STATEMENT_ID, statement_details FROM Statements


Question: Show statement id, statement detail, account detail for accounts.

Context: CREATE TABLE Accounts (statement_id VARCHAR, account_details VARCHAR); CREATE TABLE Statements (statement_details VARCHAR, statement_id VARCHAR)

SELECT T1.statement_id, T2.statement_details, T1.account_details FROM Accounts AS T1 JOIN Statements AS T2 ON T1.statement_id = T2.statement_id


Question: Show all statement id and the number of accounts for each statement.

Context: CREATE TABLE Accounts (STATEMENT_ID VARCHAR)

SELECT STATEMENT_ID, COUNT(*) FROM Accounts GROUP BY STATEMENT_ID


Question: Show the statement id and the statement detail for the statement with most number of accounts.

Context: CREATE TABLE Accounts (statement_id VARCHAR); CREATE TABLE Statements (statement_details VARCHAR, statement_id VARCHAR)

SELECT T1.statement_id, T2.statement_details FROM Accounts AS T1 JOIN Statements AS T2 ON T1.statement_id = T2.statement_id GROUP BY T1.statement_id ORDER BY COUNT(*) DESC LIMIT 1


Question: Show the number of documents.

Context: CREATE TABLE Documents (Id VARCHAR)


Question: List the document type code, document name, and document description for the document with name 'Noel CV' or name 'King Book'.

Context: CREATE TABLE Documents (document_type_code VARCHAR, document_name VARCHAR, document_description VARCHAR)

SELECT document_type_code, document_name, document_description FROM Documents WHERE document_name = 'Noel CV' OR document_name = 'King Book'


Question: Show the ids and names of all documents.

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

SELECT document_id, document_name FROM Documents


Question: Find names and ids of all documents with document type code BK.

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

SELECT document_name, document_id FROM Documents WHERE document_type_code = "BK"


Question: How many documents are with document type code BK for each product id?

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

SELECT COUNT(*), project_id FROM Documents WHERE document_type_code = "BK" GROUP BY project_id


Question: Show the document name and the document date for all documents on project with details 'Graph Database project'.

Context: CREATE TABLE Documents (project_id VARCHAR); CREATE TABLE projects (project_id VARCHAR, project_details VARCHAR)

SELECT document_name, document_date FROM Documents AS T1 JOIN projects AS T2 ON T1.project_id = T2.project_id WHERE T2.project_details = 'Graph Database project'


Question: Show project ids and the number of documents in each project.

Context: CREATE TABLE Documents (project_id VARCHAR)

SELECT project_id, COUNT(*) FROM Documents GROUP BY project_id


Question: What is the id of the project with least number of documents?

SELECT project_id FROM Documents GROUP BY project_id ORDER BY COUNT(*) LIMIT 1


Question: Show the ids for projects with at least 2 documents.

SELECT project_id FROM Documents GROUP BY project_id HAVING COUNT(*) >= 2


Question: List document type codes and the number of documents in each code.

Context: CREATE TABLE Documents (document_type_code VARCHAR)

SELECT document_type_code, COUNT(*) FROM Documents GROUP BY document_type_code


Question: What is the document type code with most number of documents?

SELECT document_type_code FROM Documents GROUP BY document_type_code ORDER BY COUNT(*) DESC LIMIT 1


Question: Show the document type code with fewer than 3 documents.

SELECT document_type_code FROM Documents GROUP BY document_type_code HAVING COUNT(*) < 3


Question: Show the statement detail and the corresponding document name for the statement with detail 'Private Project'.

Context: CREATE TABLE Statements (statement_details VARCHAR, statement_id VARCHAR); CREATE TABLE Documents (document_name VARCHAR, document_id VARCHAR)

SELECT T1.statement_details, T2.document_name FROM Statements AS T1 JOIN Documents AS T2 ON T1.statement_id = T2.document_id WHERE T1.statement_details = 'Private Project'


Question: Show all document type codes, document type names, document type descriptions.

Context: CREATE TABLE Ref_document_types (document_type_code VARCHAR, document_type_name VARCHAR, document_type_description VARCHAR)

SELECT document_type_code, document_type_name, document_type_description FROM Ref_document_types


Question: What is the document type description for document type named Film?

Context: CREATE TABLE Ref_document_types (document_type_description VARCHAR, document_type_name VARCHAR)

SELECT document_type_description FROM Ref_document_types WHERE document_type_name = "Film"


Question: What is the document type name and the document type description and creation date for all the documents?

Context: CREATE TABLE Ref_document_types (document_type_name VARCHAR, document_type_description VARCHAR, document_type_code VARCHAR); CREATE TABLE Documents (Document_date VARCHAR, document_type_code VARCHAR)

SELECT T1.document_type_name, T1.document_type_description, T2.Document_date FROM Ref_document_types AS T1 JOIN Documents AS T2 ON T1.document_type_code = T2.document_type_code


Question: Show the number of projects.

Context: CREATE TABLE Projects (Id VARCHAR)


Question: List ids and details for all projects.

Context: CREATE TABLE Projects (project_id VARCHAR, project_details VARCHAR)

SELECT project_id, project_details FROM Projects


Question: What is the project id and detail for the project with at least two documents?

Context: CREATE TABLE Projects (project_id VARCHAR, project_details VARCHAR); CREATE TABLE Documents (project_id VARCHAR)

SELECT T1.project_id, T1.project_details FROM Projects AS T1 JOIN Documents AS T2 ON T1.project_id = T2.project_id GROUP BY T1.project_id HAVING COUNT(*) > 2


Question: What is the project detail for the project with document "King Book"?

Context: CREATE TABLE Projects (project_details VARCHAR, project_id VARCHAR); CREATE TABLE Documents (project_id VARCHAR, document_name VARCHAR)

SELECT T1.project_details FROM Projects AS T1 JOIN Documents AS T2 ON T1.project_id = T2.project_id WHERE T2.document_name = "King Book"


Question: How many budget types do we have?

Context: CREATE TABLE Ref_budget_codes (Id VARCHAR)


Question: List all budget type codes and descriptions.

Context: CREATE TABLE Ref_budget_codes (budget_type_code VARCHAR, budget_type_description VARCHAR)

SELECT budget_type_code, budget_type_description FROM Ref_budget_codes


Question: What is the description for the budget type with code ORG?

Context: CREATE TABLE Ref_budget_codes (budget_type_description VARCHAR, budget_type_code VARCHAR)

SELECT budget_type_description FROM Ref_budget_codes WHERE budget_type_code = "ORG"


Question: How many documents have expenses?

Context: CREATE TABLE Documents_with_expenses (Id VARCHAR)

SELECT COUNT(*) FROM Documents_with_expenses


Question: What are the document ids for the budget type code 'SF'?

Context: CREATE TABLE Documents_with_expenses (document_id VARCHAR, budget_type_code VARCHAR)

SELECT document_id FROM Documents_with_expenses WHERE budget_type_code = 'SF'


Question: Show the budget type code and description and the corresponding document id.

Context: CREATE TABLE Ref_budget_codes (budget_type_code VARCHAR, budget_type_description VARCHAR); CREATE TABLE Documents_with_expenses (document_id VARCHAR, budget_type_code VARCHAR)

SELECT T2.budget_type_code, T2.budget_type_description, T1.document_id FROM Documents_with_expenses AS T1 JOIN Ref_budget_codes AS T2 ON T1.budget_type_code = T2.budget_type_code


Question: Show ids for all documents with budget types described as 'Government'.

Context: CREATE TABLE Documents_with_expenses (document_id VARCHAR, Budget_Type_code VARCHAR); CREATE TABLE Ref_Budget_Codes (Budget_Type_code VARCHAR, budget_type_Description VARCHAR)

SELECT T1.document_id FROM Documents_with_expenses AS T1 JOIN Ref_Budget_Codes AS T2 ON T1.Budget_Type_code = T2.Budget_Type_code WHERE T2.budget_type_Description = "Government"


Question: Show budget type codes and the number of documents in each budget type.

Context: CREATE TABLE Documents_with_expenses (budget_type_code VARCHAR)

SELECT budget_type_code, COUNT(*) FROM Documents_with_expenses GROUP BY budget_type_code


Question: What is the budget type code with most number of documents.

SELECT budget_type_code FROM Documents_with_expenses GROUP BY budget_type_code ORDER BY COUNT(*) DESC LIMIT 1


Question: What are the ids of documents which don't have expense budgets?

Context: CREATE TABLE Documents (document_id VARCHAR); CREATE TABLE Documents_with_expenses (document_id VARCHAR)

SELECT document_id FROM Documents EXCEPT SELECT document_id FROM Documents_with_expenses


Question: Show ids for all documents in type CV without expense budgets.

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

SELECT document_id FROM Documents WHERE document_type_code = "CV" EXCEPT SELECT document_id FROM Documents_with_expenses


Question: What are the ids of documents with letter 's' in the name with any expense budgets.

Context: CREATE TABLE Documents_with_expenses (document_id VARCHAR); CREATE TABLE Documents (document_id VARCHAR, document_name VARCHAR)

SELECT T1.document_id FROM Documents AS T1 JOIN Documents_with_expenses AS T2 ON T1.document_id = T2.document_id WHERE T1.document_name LIKE '%s%'


Question: How many documents do not have any expense?

SELECT COUNT(*) FROM Documents WHERE NOT document_id IN (SELECT document_id FROM Documents_with_expenses)


Question: What are the dates for the documents with both 'GV' type and 'SF' type expenses?

Context: CREATE TABLE Documents_with_Expenses (document_id VARCHAR, budget_type_code VARCHAR); CREATE TABLE Documents (document_date VARCHAR, document_id VARCHAR)

SELECT T1.document_date FROM Documents AS T1 JOIN Documents_with_Expenses AS T2 ON T1.document_id = T2.document_id WHERE T2.budget_type_code = 'GV' INTERSECT SELECT T1.document_date FROM Documents AS T1 JOIN Documents_with_Expenses AS T2 ON T1.document_id = T2.document_id WHERE T2.budget_type_code = 'SF'


Question: What are the account details with the largest value or with value having char '5' in it?

Context: CREATE TABLE Accounts (Account_details INTEGER)

SELECT MAX(Account_details) FROM Accounts UNION SELECT Account_details FROM Accounts WHERE Account_details LIKE "%5%"


Question: Find the total number of scientists.

Context: CREATE TABLE scientists (Id VARCHAR)


Question: Find the total hours of all projects.

Context: CREATE TABLE projects (hours INTEGER)


Question: How many different scientists are assigned to any project?

Context: CREATE TABLE assignedto (scientist VARCHAR)

SELECT COUNT(DISTINCT scientist) FROM assignedto


Question: Find the number of distinct projects.

Context: CREATE TABLE projects (name VARCHAR)

SELECT COUNT(DISTINCT name) FROM projects


Question: Find the average hours of all projects.

Context: CREATE TABLE projects (hours INTEGER)


Question: Find the name of project that continues for the longest time.

Context: CREATE TABLE projects (name VARCHAR, hours VARCHAR)

SELECT name FROM projects ORDER BY hours DESC LIMIT 1


Question: List the name of all projects that are operated longer than the average working hours of all projects.

Context: CREATE TABLE projects (name VARCHAR, hours INTEGER)

SELECT name FROM projects WHERE hours > (SELECT AVG(hours) FROM projects)


Question: Find the name and hours of project that has the most number of scientists.

Context: CREATE TABLE assignedto (project VARCHAR); CREATE TABLE projects (name VARCHAR, hours VARCHAR, code VARCHAR)

SELECT T1.name, T1.hours FROM projects AS T1 JOIN assignedto AS T2 ON T1.code = T2.project GROUP BY T2.project ORDER BY COUNT(*) DESC LIMIT 1


Question: Find the name of the project for which a scientist whose name contains ‘Smith’ is assigned to.

Context: CREATE TABLE scientists (SSN VARCHAR, name VARCHAR); CREATE TABLE assignedto (project VARCHAR, scientist VARCHAR); CREATE TABLE projects (name VARCHAR, code VARCHAR)

SELECT T2.name FROM assignedto AS T1 JOIN projects AS T2 ON T1.project = T2.code JOIN scientists AS T3 ON T1.scientist = T3.SSN WHERE T3.name LIKE '%Smith%'


Question: Find the total hours of the projects that scientists named Michael Rogers or Carol Smith are assigned to.

Context: CREATE TABLE scientists (SSN VARCHAR, name VARCHAR); CREATE TABLE projects (hours INTEGER, code VARCHAR); CREATE TABLE assignedto (project VARCHAR, scientist VARCHAR)

SELECT SUM(T2.hours) FROM assignedto AS T1 JOIN projects AS T2 ON T1.project = T2.code JOIN scientists AS T3 ON T1.scientist = T3.SSN WHERE T3.name = 'Michael Rogers' OR T3.name = 'Carol Smith'


Question: Find the name of projects that require between 100 and 300 hours of work.

SELECT name FROM projects WHERE hours BETWEEN 100 AND 300


Question: Find the name of the scientist who worked on both a project named 'Matter of Time' and a project named 'A Puzzling Parallax'.

Context: CREATE TABLE projects (code VARCHAR, name VARCHAR); CREATE TABLE scientists (name VARCHAR, SSN VARCHAR); CREATE TABLE assignedto (project VARCHAR, scientist VARCHAR)

SELECT T3.name FROM assignedto AS T1 JOIN projects AS T2 ON T1.project = T2.code JOIN scientists AS T3 ON T1.scientist = T3.SSN WHERE T2.name = 'Matter of Time' INTERSECT SELECT T3.name FROM assignedto AS T1 JOIN projects AS T2 ON T1.project = T2.code JOIN scientists AS T3 ON T1.scientist = T3.SSN WHERE T2.name = 'A Puzzling Parallax'


Question: List the names of all scientists sorted in alphabetical order.

Context: CREATE TABLE scientists (name VARCHAR)

SELECT name FROM scientists ORDER BY name


Question: Find the number of scientists involved for each project name.

Context: CREATE TABLE assignedto (project VARCHAR); CREATE TABLE projects (name VARCHAR, code VARCHAR)

SELECT COUNT(*), T1.name FROM projects AS T1 JOIN assignedto AS T2 ON T1.code = T2.project GROUP BY T1.name


Question: Find the number of scientists involved for the projects that require more than 300 hours.

Context: CREATE TABLE assignedto (project VARCHAR); CREATE TABLE projects (name VARCHAR, code VARCHAR, hours INTEGER)

SELECT COUNT(*), T1.name FROM projects AS T1 JOIN assignedto AS T2 ON T1.code = T2.project WHERE T1.hours > 300 GROUP BY T1.name


Question: Find the number of projects which each scientist is working on and scientist's name.

Context: CREATE TABLE scientists (name VARCHAR, ssn VARCHAR); CREATE TABLE assignedto (scientist VARCHAR)

SELECT COUNT(*), T1.name FROM scientists AS T1 JOIN assignedto AS T2 ON T1.ssn = T2.scientist GROUP BY T1.name


Question: Find the SSN and name of scientists who are assigned to the project with the longest hours.

Context: CREATE TABLE scientists (ssn VARCHAR, name VARCHAR, SSN VARCHAR); CREATE TABLE projects (code VARCHAR, hours INTEGER); CREATE TABLE assignedto (project VARCHAR, scientist VARCHAR); CREATE TABLE projects (hours INTEGER)

SELECT T3.ssn, T3.name FROM assignedto AS T1 JOIN projects AS T2 ON T1.project = T2.code JOIN scientists AS T3 ON T1.scientist = T3.SSN WHERE T2.hours = (SELECT MAX(hours) FROM projects)


Question: Find the name of scientists who are assigned to some project.

Context: CREATE TABLE assignedto (scientist VARCHAR); CREATE TABLE scientists (name VARCHAR, ssn VARCHAR)

SELECT T2.name FROM assignedto AS T1 JOIN scientists AS T2 ON T1.scientist = T2.ssn


Question: Select the project names which are not assigned yet.

Context: CREATE TABLE Projects (Name VARCHAR, Code VARCHAR, Project VARCHAR); CREATE TABLE AssignedTo (Name VARCHAR, Code VARCHAR, Project VARCHAR)

SELECT Name FROM Projects WHERE NOT Code IN (SELECT Project FROM AssignedTo)


Question: Find the name of scientists who are not assigned to any project.

Context: CREATE TABLE scientists (Name VARCHAR, ssn VARCHAR, scientist VARCHAR); CREATE TABLE AssignedTo (Name VARCHAR, ssn VARCHAR, scientist VARCHAR)

SELECT Name FROM scientists WHERE NOT ssn IN (SELECT scientist FROM AssignedTo)


Question: Find the number of scientists who are not assigned to any project.

Context: CREATE TABLE AssignedTo (ssn VARCHAR, scientist VARCHAR); CREATE TABLE scientists (ssn VARCHAR, scientist VARCHAR)

SELECT COUNT(*) FROM scientists WHERE NOT ssn IN (SELECT scientist FROM AssignedTo)


Question: Find the names of scientists who are not working on the project with the highest hours.

Context: CREATE TABLE scientists (name VARCHAR, SSN VARCHAR); CREATE TABLE assignedto (project VARCHAR, scientist VARCHAR); CREATE TABLE projects (code VARCHAR, hours INTEGER); CREATE TABLE scientists (name VARCHAR, hours INTEGER); CREATE TABLE projects (name VARCHAR, hours INTEGER)

SELECT name FROM scientists EXCEPT SELECT T3.name FROM assignedto AS T1 JOIN projects AS T2 ON T1.project = T2.code JOIN scientists AS T3 ON T1.scientist = T3.SSN WHERE T2.hours = (SELECT MAX(hours) FROM projects)


Question: List all the scientists' names, their projects' names, and the hours worked by that scientist on each project, in alphabetical order of project name, and then scientist name.

Context: CREATE TABLE AssignedTo (Scientist VARCHAR, Project VARCHAR); CREATE TABLE Projects (Name VARCHAR, Hours VARCHAR, Code VARCHAR); CREATE TABLE Scientists (Name VARCHAR, SSN VARCHAR)

SELECT T1.Name, T3.Name, T3.Hours FROM Scientists AS T1 JOIN AssignedTo AS T2 ON T1.SSN = T2.Scientist JOIN Projects AS T3 ON T2.Project = T3.Code ORDER BY T3.Name, T1.Name


Question: Find name of the project that needs the least amount of time to finish and the name of scientists who worked on it.

Context: CREATE TABLE scientists (name VARCHAR, SSN VARCHAR); CREATE TABLE assignedto (project VARCHAR, scientist VARCHAR); CREATE TABLE projects (name VARCHAR, code VARCHAR, hours INTEGER); CREATE TABLE projects (hours INTEGER)

SELECT T2.name, T3.name FROM assignedto AS T1 JOIN projects AS T2 ON T1.project = T2.code JOIN scientists AS T3 ON T1.scientist = T3.SSN WHERE T2.hours = (SELECT MIN(hours) FROM projects)


Question: What is the name of the highest rated wine?

Context: CREATE TABLE WINE (Name VARCHAR, Score VARCHAR)

SELECT Name FROM WINE ORDER BY Score LIMIT 1


Question: Which winery is the wine that has the highest score from?

Context: CREATE TABLE WINE (Winery VARCHAR, SCORE VARCHAR)

SELECT Winery FROM WINE ORDER BY SCORE LIMIT 1


Question: Find the names of all wines produced in 2008.

Context: CREATE TABLE WINE (Name VARCHAR, YEAR VARCHAR)

SELECT Name FROM WINE WHERE YEAR = "2008"


Question: List the grapes and appelations of all wines.

Context: CREATE TABLE WINE (Grape VARCHAR, Appelation VARCHAR)


Question: List the names and scores of all wines.


Question: List the area and county of all appelations.

Context: CREATE TABLE APPELLATIONS (Area VARCHAR, County VARCHAR)


Question: What are the prices of wines produced before the year of 2010?

Context: CREATE TABLE WINE (Price VARCHAR, YEAR INTEGER)

SELECT Price FROM WINE WHERE YEAR < 2010


Question: List the names of all distinct wines that have scores higher than 90.

Context: CREATE TABLE WINE (Name VARCHAR, score INTEGER)


Question: List the names of all distinct wines that are made of red color grape.

Context: CREATE TABLE GRAPES (Grape VARCHAR, Color VARCHAR); CREATE TABLE WINE (Name VARCHAR, Grape VARCHAR)

SELECT DISTINCT T2.Name FROM GRAPES AS T1 JOIN WINE AS T2 ON T1.Grape = T2.Grape WHERE T1.Color = "Red"


Question: Find the names of all distinct wines that have appellations in North Coast area.

Context: CREATE TABLE APPELLATIONs (Appelation VARCHAR, Area VARCHAR); CREATE TABLE WINE (Name VARCHAR, Appelation VARCHAR)

SELECT DISTINCT T2.Name FROM APPELLATIONs AS T1 JOIN WINE AS T2 ON T1.Appelation = T2.Appelation WHERE T1.Area = "North Coast"


Question: How many wines are produced at Robert Biale winery?

Context: CREATE TABLE WINE (Winery VARCHAR)

SELECT COUNT(*) FROM WINE WHERE Winery = "Robert Biale"


Question: How many appelations are in Napa Country?

Context: CREATE TABLE APPELLATIONS (County VARCHAR)

SELECT COUNT(*) FROM APPELLATIONS WHERE County = "Napa"


Question: Give me the average prices of wines that are produced by appelations in Sonoma County.

Context: CREATE TABLE WINE (Price INTEGER, Appelation VARCHAR); CREATE TABLE APPELLATIONS (Appelation VARCHAR, County VARCHAR)

SELECT AVG(T2.Price) FROM APPELLATIONS AS T1 JOIN WINE AS T2 ON T1.Appelation = T2.Appelation WHERE T1.County = "Sonoma"


Question: What are the names and scores of wines that are made of white color grapes?

Context: CREATE TABLE GRAPES (Grape VARCHAR, Color VARCHAR); CREATE TABLE WINE (Name VARCHAR, Score VARCHAR, Grape VARCHAR)

SELECT T2.Name, T2.Score FROM GRAPES AS T1 JOIN WINE AS T2 ON T1.Grape = T2.Grape WHERE T1.Color = "White"


Question: Find the maximum price of wins from the appelations in Central Coast area and produced before the year of 2005.

Context: CREATE TABLE APPELLATIONS (Appelation VARCHAR, Area VARCHAR); CREATE TABLE WINE (Price INTEGER, Appelation VARCHAR, year VARCHAR)

SELECT MAX(T2.Price) FROM APPELLATIONS AS T1 JOIN WINE AS T2 ON T1.Appelation = T2.Appelation WHERE T1.Area = "Central Coast" AND T2.year < 2005


Question: Find the the grape whose white color grapes are used to produce wines with scores higher than 90.

Context: CREATE TABLE GRAPES (Grape VARCHAR, Color VARCHAR); CREATE TABLE WINE (Grape VARCHAR, score VARCHAR)

SELECT DISTINCT T1.Grape FROM GRAPES AS T1 JOIN WINE AS T2 ON T1.Grape = T2.Grape WHERE T1.Color = "White" AND T2.score > 90


Question: What are the wines that have prices higher than 50 and made of Red color grapes?

Context: CREATE TABLE WINE (Name VARCHAR, Grape VARCHAR, price VARCHAR); CREATE TABLE Grapes (Grape VARCHAR, Color VARCHAR)

SELECT T2.Name FROM Grapes AS T1 JOIN WINE AS T2 ON T1.Grape = T2.Grape WHERE T1.Color = "Red" AND T2.price > 50


Question: What are the wines that have prices lower than 50 and have appelations in Monterey county?

Context: CREATE TABLE APPELLATIONS (Appelation VARCHAR, County VARCHAR); CREATE TABLE WINE (Name VARCHAR, Appelation VARCHAR, price VARCHAR)

SELECT T2.Name FROM APPELLATIONS AS T1 JOIN WINE AS T2 ON T1.Appelation = T2.Appelation WHERE T1.County = "Monterey" AND T2.price < 50


Question: What are the numbers of wines for different grapes?

Context: CREATE TABLE WINE (Grape VARCHAR)

SELECT COUNT(*), Grape FROM WINE GROUP BY Grape


Question: What are the average prices of wines for different years?

Context: CREATE TABLE WINE (YEAR VARCHAR, Price INTEGER)

SELECT AVG(Price), YEAR FROM WINE GROUP BY YEAR


Question: Find the distinct names of all wines that have prices higher than some wines from John Anthony winery.

Context: CREATE TABLE wine (Name VARCHAR, Price INTEGER, Winery VARCHAR); CREATE TABLE WINE (Name VARCHAR, Price INTEGER, Winery VARCHAR)

SELECT DISTINCT Name FROM WINE WHERE Price > (SELECT MIN(Price) FROM wine WHERE Winery = "John Anthony")


Question: List the names of all distinct wines in alphabetical order.

Context: CREATE TABLE WINE (Name VARCHAR)

SELECT DISTINCT Name FROM WINE ORDER BY Name


Question: List the names of all distinct wines ordered by price.

Context: CREATE TABLE WINE (Name VARCHAR, price VARCHAR)

SELECT DISTINCT Name FROM WINE ORDER BY price


Question: What is the area of the appelation that produces the highest number of wines before the year of 2010?

Context: CREATE TABLE WINE (Appelation VARCHAR, year VARCHAR); CREATE TABLE APPELLATIONS (Area VARCHAR, Appelation VARCHAR)

SELECT T1.Area FROM APPELLATIONS AS T1 JOIN WINE AS T2 ON T1.Appelation = T2.Appelation GROUP BY T2.Appelation HAVING T2.year < 2010 ORDER BY COUNT(*) DESC LIMIT 1


Question: What is the color of the grape whose wine products has the highest average price?

Context: CREATE TABLE GRAPES (Color VARCHAR, Grape VARCHAR); CREATE TABLE WINE (Grape VARCHAR)

SELECT T1.Color FROM GRAPES AS T1 JOIN WINE AS T2 ON T1.Grape = T2.Grape GROUP BY T2.Grape ORDER BY AVG(Price) DESC LIMIT 1


Question: Find the distinct names of wines produced before the year of 2000 or after the year of 2010.

Context: CREATE TABLE WINE (Name VARCHAR, YEAR VARCHAR)

SELECT DISTINCT Name FROM WINE WHERE YEAR < 2000 OR YEAR > 2010


Question: Find the distinct winery of wines having price between 50 and 100.

Context: CREATE TABLE WINE (Winery VARCHAR, Price INTEGER)

SELECT DISTINCT Winery FROM WINE WHERE Price BETWEEN 50 AND 100


Question: What are the average prices and cases of wines produced in the year of 2009 and made of Zinfandel grape?

Context: CREATE TABLE WINE (Price INTEGER, Cases INTEGER, YEAR VARCHAR, Grape VARCHAR)

SELECT AVG(Price), AVG(Cases) FROM WINE WHERE YEAR = 2009 AND Grape = "Zinfandel"


Question: What are the maximum price and score of wines produced by St. Helena appelation?

Context: CREATE TABLE WINE (Price INTEGER, Score INTEGER, Appelation VARCHAR)

SELECT MAX(Price), MAX(Score) FROM WINE WHERE Appelation = "St. Helena"


Question: What are the maximum price and score of wines in each year?

Context: CREATE TABLE WINE (YEAR VARCHAR, Price INTEGER, Score INTEGER)

SELECT MAX(Price), MAX(Score), YEAR FROM WINE GROUP BY YEAR


Question: What are the average price and score of wines grouped by appelation?

Context: CREATE TABLE WINE (Appelation VARCHAR, Price INTEGER, Score INTEGER)

SELECT AVG(Price), AVG(Score), Appelation FROM WINE GROUP BY Appelation


Question: Find the wineries that have at least four wines.

Context: CREATE TABLE WINE (Winery VARCHAR)

SELECT Winery FROM WINE GROUP BY Winery HAVING COUNT(*) >= 4


Question: Find the country of all appelations who have at most three wines.

Context: CREATE TABLE APPELLATIONS (County VARCHAR, Appelation VARCHAR); CREATE TABLE WINE (Appelation VARCHAR)

SELECT T1.County FROM APPELLATIONS AS T1 JOIN WINE AS T2 ON T1.Appelation = T2.Appelation GROUP BY T2.Appelation HAVING COUNT(*) <= 3


Question: What are the names of wines whose production year are before the year of all wines by Brander winery?

Context: CREATE TABLE WINE (Name VARCHAR, YEAR INTEGER, Winery VARCHAR)

SELECT Name FROM WINE WHERE YEAR < (SELECT MIN(YEAR) FROM WINE WHERE Winery = "Brander")


Question: What are the names of wines that are more expensive then all wines made in the year 2006?

Context: CREATE TABLE WINE (Name VARCHAR, Price INTEGER, YEAR VARCHAR)

SELECT Name FROM WINE WHERE Price > (SELECT MAX(Price) FROM WINE WHERE YEAR = 2006)


Question: Find the top 3 wineries with the greatest number of wines made of white color grapes.

Context: CREATE TABLE GRAPES (GRAPE VARCHAR, Color VARCHAR); CREATE TABLE WINE (Winery VARCHAR, GRAPE VARCHAR)

SELECT T2.Winery FROM GRAPES AS T1 JOIN WINE AS T2 ON T1.GRAPE = T2.GRAPE WHERE T1.Color = "White" GROUP BY T2.Winery ORDER BY COUNT(*) DESC LIMIT 3


Question: List the grape, winery and year of the wines whose price is bigger than 100 ordered by year.

Context: CREATE TABLE WINE (Grape VARCHAR, Winery VARCHAR, YEAR VARCHAR, Price INTEGER)

SELECT Grape, Winery, YEAR FROM WINE WHERE Price > 100 ORDER BY YEAR


Question: List the grape, appelation and name of wines whose score is higher than 93 ordered by Name.

Context: CREATE TABLE WINE (Grape VARCHAR, Appelation VARCHAR, Name VARCHAR, Score INTEGER)

SELECT Grape, Appelation, Name FROM WINE WHERE Score > 93 ORDER BY Name


Question: Find the appelations that produce wines after the year of 2008 but not in Central Coast area.

Context: CREATE TABLE WINE (Appelation VARCHAR, YEAR INTEGER, Area VARCHAR); CREATE TABLE APPELLATIONS (Appelation VARCHAR, YEAR INTEGER, Area VARCHAR)

SELECT Appelation FROM WINE WHERE YEAR > 2008 EXCEPT SELECT Appelation FROM APPELLATIONS WHERE Area = "Central Coast"


Question: Find the average price of wines that are not produced from Sonoma county.

Context: CREATE TABLE wine (price INTEGER, Appelation VARCHAR); CREATE TABLE APPELLATIONS (Appelation VARCHAR, County VARCHAR); CREATE TABLE WINE (Appelation VARCHAR)

SELECT AVG(price) FROM wine WHERE NOT Appelation IN (SELECT T1.Appelation FROM APPELLATIONS AS T1 JOIN WINE AS T2 ON T1.Appelation = T2.Appelation WHERE T1.County = 'Sonoma')


Question: Find the county where produces the most number of wines with score higher than 90.

Context: CREATE TABLE WINE (Appelation VARCHAR, Score INTEGER); CREATE TABLE APPELLATIONS (County VARCHAR, Appelation VARCHAR)

SELECT T1.County FROM APPELLATIONS AS T1 JOIN WINE AS T2 ON T1.Appelation = T2.Appelation WHERE T2.Score > 90 GROUP BY T1.County ORDER BY COUNT(*) DESC LIMIT 1


Question: How many train stations are there?

Context: CREATE TABLE station (Id VARCHAR)


Question: Show the name, location, and number of platforms for all stations.

Context: CREATE TABLE station (name VARCHAR, LOCATION VARCHAR, number_of_platforms VARCHAR)

SELECT name, LOCATION, number_of_platforms FROM station


Question: What are all locations of train stations?

Context: CREATE TABLE station (LOCATION VARCHAR)


Question: Show the names and total passengers for all train stations not in London.

Context: CREATE TABLE station (name VARCHAR, total_passengers VARCHAR, LOCATION VARCHAR)

SELECT name, total_passengers FROM station WHERE LOCATION <> 'London'


Question: Show the names and main services for train stations that have the top three total number of passengers.

Context: CREATE TABLE station (name VARCHAR, main_services VARCHAR, total_passengers VARCHAR)

SELECT name, main_services FROM station ORDER BY total_passengers DESC LIMIT 3


Question: What is the average and maximum number of total passengers for train stations in London or Glasgow?

Context: CREATE TABLE station (total_passengers INTEGER, LOCATION VARCHAR)

SELECT AVG(total_passengers), MAX(total_passengers) FROM station WHERE LOCATION = 'London' OR LOCATION = 'Glasgow'


Question: Show all locations and the total number of platforms and passengers for all train stations in each location.

Context: CREATE TABLE station (LOCATION VARCHAR, number_of_platforms INTEGER, total_passengers INTEGER)

SELECT LOCATION, SUM(number_of_platforms), SUM(total_passengers) FROM station GROUP BY LOCATION


Question: Show all locations that have train stations with at least 15 platforms and train stations with more than 25 total passengers.

Context: CREATE TABLE station (LOCATION VARCHAR, number_of_platforms VARCHAR, total_passengers VARCHAR)

SELECT DISTINCT LOCATION FROM station WHERE number_of_platforms >= 15 AND total_passengers > 25


Question: Show all locations which don't have a train station with at least 15 platforms.

Context: CREATE TABLE station (LOCATION VARCHAR, number_of_platforms VARCHAR)

SELECT LOCATION FROM station EXCEPT SELECT LOCATION FROM station WHERE number_of_platforms >= 15


Question: Show the location with most number of train stations.

Context: CREATE TABLE station (LOCATION VARCHAR)

SELECT LOCATION FROM station GROUP BY LOCATION ORDER BY COUNT(*) DESC LIMIT 1


Question: Show the name, time, and service for all trains.

Context: CREATE TABLE train (name VARCHAR, TIME VARCHAR, service VARCHAR)


Question: Show the number of trains

Context: CREATE TABLE train (Id VARCHAR)


Question: Show the name and service for all trains in order by time.

Context: CREATE TABLE train (name VARCHAR, service VARCHAR, TIME VARCHAR)

SELECT name, service FROM train ORDER BY TIME


Question: Show the station name and number of trains in each station.

Context: CREATE TABLE station (name VARCHAR, station_id VARCHAR); CREATE TABLE train_station (station_id VARCHAR)

SELECT T2.name, COUNT(*) FROM train_station AS T1 JOIN station AS T2 ON T1.station_id = T2.station_id GROUP BY T1.station_id


Question: show the train name and station name for each train.

Context: CREATE TABLE station (name VARCHAR, station_id VARCHAR); CREATE TABLE train (name VARCHAR, train_id VARCHAR); CREATE TABLE train_station (station_id VARCHAR, train_id VARCHAR)

SELECT T2.name, T3.name FROM train_station AS T1 JOIN station AS T2 ON T1.station_id = T2.station_id JOIN train AS T3 ON T3.train_id = T1.train_id


Question: Show all train names and times in stations in London in descending order by train time.

Context: CREATE TABLE train_station (station_id VARCHAR, train_id VARCHAR); CREATE TABLE station (station_id VARCHAR, location VARCHAR); CREATE TABLE train (name VARCHAR, time VARCHAR, train_id VARCHAR)

SELECT T3.name, T3.time FROM train_station AS T1 JOIN station AS T2 ON T1.station_id = T2.station_id JOIN train AS T3 ON T3.train_id = T1.train_id WHERE T2.location = 'London' ORDER BY T3.time DESC


Question: Show the station name with greatest number of trains.

SELECT T2.name FROM train_station AS T1 JOIN station AS T2 ON T1.station_id = T2.station_id GROUP BY T1.station_id ORDER BY COUNT(*) DESC LIMIT 1


Question: Show the station name with at least two trains.

SELECT T2.name FROM train_station AS T1 JOIN station AS T2 ON T1.station_id = T2.station_id GROUP BY T1.station_id HAVING COUNT(*) >= 2


Question: Show all locations with only 1 station.

Context: CREATE TABLE station (LOCATION VARCHAR)

SELECT LOCATION FROM station GROUP BY LOCATION HAVING COUNT(*) = 1


Question: Show station names without any trains.

Context: CREATE TABLE station (name VARCHAR, station_id VARCHAR); CREATE TABLE train_station (name VARCHAR, station_id VARCHAR)

SELECT name FROM station WHERE NOT station_id IN (SELECT station_id FROM train_station)


Question: What are the names of the stations which serve both "Ananthapuri Express" and "Guruvayur Express" trains?

Context: CREATE TABLE station (name VARCHAR, station_id VARCHAR); CREATE TABLE train (train_id VARCHAR, Name VARCHAR); CREATE TABLE train_station (station_id VARCHAR, train_id VARCHAR)

SELECT T2.name FROM train_station AS T1 JOIN station AS T2 ON T1.station_id = T2.station_id JOIN train AS T3 ON T3.train_id = T1.train_id WHERE T3.Name = "Ananthapuri Express" INTERSECT SELECT T2.name FROM train_station AS T1 JOIN station AS T2 ON T1.station_id = T2.station_id JOIN train AS T3 ON T3.train_id = T1.train_id WHERE T3.Name = "Guruvayur Express"


Question: Find the names of the trains that do not pass any station located in London.

Context: CREATE TABLE station (station_id VARCHAR); CREATE TABLE train_station (station_id VARCHAR); CREATE TABLE train_station (train_id VARCHAR, station_id VARCHAR); CREATE TABLE train (name VARCHAR, train_id VARCHAR)

SELECT T2.name FROM train_station AS T1 JOIN train AS T2 ON T1.train_id = T2.train_id WHERE NOT T1.station_id IN (SELECT T4.station_id FROM train_station AS T3 JOIN station AS T4 ON T3.station_id = T4.station_id WHERE t4.location = "London")


Question: List the names and locations of all stations ordered by their yearly entry exit and interchange amounts.

Context: CREATE TABLE station (name VARCHAR, LOCATION VARCHAR, Annual_entry_exit VARCHAR, Annual_interchanges VARCHAR)

SELECT name, LOCATION FROM station ORDER BY Annual_entry_exit, Annual_interchanges


Question: List all vehicle id

Context: CREATE TABLE Vehicles (vehicle_id VARCHAR)


Question: How many vehicle in total?

Context: CREATE TABLE Vehicles (Id VARCHAR)


Question: Show the detail of vehicle with id 1.

Context: CREATE TABLE Vehicles (vehicle_details VARCHAR, vehicle_id VARCHAR)

SELECT vehicle_details FROM Vehicles WHERE vehicle_id = 1


Question: List the first name middle name and last name of all staff.

Context: CREATE TABLE Staff (first_name VARCHAR, middle_name VARCHAR, last_name VARCHAR)

SELECT first_name, middle_name, last_name FROM Staff


Question: What is the birthday of the staff member with first name as Janessa and last name as Sawayn?

Context: CREATE TABLE Staff (date_of_birth VARCHAR, first_name VARCHAR, last_name VARCHAR)

SELECT date_of_birth FROM Staff WHERE first_name = "Janessa" AND last_name = "Sawayn"


Question: When did the staff member with first name as Janessa and last name as Sawayn join the company?

Context: CREATE TABLE Staff (date_joined_staff VARCHAR, first_name VARCHAR, last_name VARCHAR)

SELECT date_joined_staff FROM Staff WHERE first_name = "Janessa" AND last_name = "Sawayn"


Question: When did the staff member with first name as Janessa and last name as Sawayn leave the company?

Context: CREATE TABLE Staff (date_left_staff VARCHAR, first_name VARCHAR, last_name VARCHAR)

SELECT date_left_staff FROM Staff WHERE first_name = "Janessa" AND last_name = "Sawayn"


Question: How many staff have the first name Ludie?

Context: CREATE TABLE Staff (first_name VARCHAR)

SELECT COUNT(*) FROM Staff WHERE first_name = "Ludie"


Question: What is the nickname of staff with first name as Janessa and last name as Sawayn?

Context: CREATE TABLE Staff (nickname VARCHAR, first_name VARCHAR, last_name VARCHAR)

SELECT nickname FROM Staff WHERE first_name = "Janessa" AND last_name = "Sawayn"


Question: How many staff in total?

Context: CREATE TABLE Staff (Id VARCHAR)


Question: Which city does staff with first name as Janessa and last name as Sawayn live?

Context: CREATE TABLE Staff (staff_address_id VARCHAR, first_name VARCHAR, last_name VARCHAR); CREATE TABLE Addresses (city VARCHAR, address_id VARCHAR)

SELECT T1.city FROM Addresses AS T1 JOIN Staff AS T2 ON T1.address_id = T2.staff_address_id WHERE T2.first_name = "Janessa" AND T2.last_name = "Sawayn"


Question: Which country and state does staff with first name as Janessa and last name as Sawayn lived?

Context: CREATE TABLE Addresses (country VARCHAR, state_province_county VARCHAR, address_id VARCHAR); CREATE TABLE Staff (staff_address_id VARCHAR, first_name VARCHAR, last_name VARCHAR)

SELECT T1.country, T1.state_province_county FROM Addresses AS T1 JOIN Staff AS T2 ON T1.address_id = T2.staff_address_id WHERE T2.first_name = "Janessa" AND T2.last_name = "Sawayn"


Question: How long is the total lesson time took by customer with first name as Rylan and last name as Goodwin?

Context: CREATE TABLE Lessons (lesson_time INTEGER, customer_id VARCHAR); CREATE TABLE Customers (customer_id VARCHAR, first_name VARCHAR, last_name VARCHAR)

SELECT SUM(T1.lesson_time) FROM Lessons AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id WHERE T2.first_name = "Rylan" AND T2.last_name = "Goodwin"


Question: What is the zip code of staff with first name as Janessa and last name as Sawayn lived?

Context: CREATE TABLE Addresses (zip_postcode VARCHAR, address_id VARCHAR); CREATE TABLE Staff (staff_address_id VARCHAR, first_name VARCHAR, last_name VARCHAR)

SELECT T1.zip_postcode FROM Addresses AS T1 JOIN Staff AS T2 ON T1.address_id = T2.staff_address_id WHERE T2.first_name = "Janessa" AND T2.last_name = "Sawayn"


Question: How many staff live in state Georgia?

Context: CREATE TABLE Addresses (state_province_county VARCHAR)

SELECT COUNT(*) FROM Addresses WHERE state_province_county = "Georgia"


Question: Find out the first name and last name of staff lived in city Damianfort.

Context: CREATE TABLE Staff (first_name VARCHAR, last_name VARCHAR, staff_address_id VARCHAR); CREATE TABLE Addresses (address_id VARCHAR, city VARCHAR)

SELECT T2.first_name, T2.last_name FROM Addresses AS T1 JOIN Staff AS T2 ON T1.address_id = T2.staff_address_id WHERE T1.city = "Damianfort"


Question: Which city lives most of staffs? List the city name and number of staffs.

Context: CREATE TABLE Staff (staff_address_id VARCHAR); CREATE TABLE Addresses (city VARCHAR, address_id VARCHAR)

SELECT T1.city, COUNT(*) FROM Addresses AS T1 JOIN Staff AS T2 ON T1.address_id = T2.staff_address_id GROUP BY T1.city ORDER BY COUNT(*) DESC LIMIT 1


Question: List the states which have between 2 to 4 staffs living there.

Context: CREATE TABLE Addresses (state_province_county VARCHAR, address_id VARCHAR); CREATE TABLE Staff (staff_address_id VARCHAR)

SELECT T1.state_province_county FROM Addresses AS T1 JOIN Staff AS T2 ON T1.address_id = T2.staff_address_id GROUP BY T1.state_province_county HAVING COUNT(*) BETWEEN 2 AND 4


Question: List the first name and last name of all customers.

Context: CREATE TABLE Customers (first_name VARCHAR, last_name VARCHAR)

SELECT first_name, last_name FROM Customers


Question: List email address and birthday of customer whose first name as Carole.

Context: CREATE TABLE Customers (email_address VARCHAR, date_of_birth VARCHAR, first_name VARCHAR)

SELECT email_address, date_of_birth FROM Customers WHERE first_name = "Carole"


Question: List phone number and email address of customer with more than 2000 outstanding balance.

Context: CREATE TABLE Customers (phone_number VARCHAR, email_address VARCHAR, amount_outstanding INTEGER)

SELECT phone_number, email_address FROM Customers WHERE amount_outstanding > 2000


Question: What is the status code, mobile phone number and email address of customer with last name as Kohler or first name as Marina?

Context: CREATE TABLE Customers (customer_status_code VARCHAR, cell_mobile_phone_number VARCHAR, email_address VARCHAR, first_name VARCHAR, last_name VARCHAR)

SELECT customer_status_code, cell_mobile_phone_number, email_address FROM Customers WHERE first_name = "Marina" OR last_name = "Kohler"


Question: When are the birthdays of customer who are classified as 'Good Customer' status?

Context: CREATE TABLE Customers (date_of_birth VARCHAR, customer_status_code VARCHAR)

SELECT date_of_birth FROM Customers WHERE customer_status_code = 'Good Customer'


Question: When did customer with first name as Carole and last name as Bernhard became a customer?

Context: CREATE TABLE Customers (date_became_customer VARCHAR, first_name VARCHAR, last_name VARCHAR)

SELECT date_became_customer FROM Customers WHERE first_name = "Carole" AND last_name = "Bernhard"


Question: List all customer status codes and the number of customers having each status code.

Context: CREATE TABLE Customers (customer_status_code VARCHAR)

SELECT customer_status_code, COUNT(*) FROM Customers GROUP BY customer_status_code


Question: Which customer status code has least number of customers?

SELECT customer_status_code FROM Customers GROUP BY customer_status_code ORDER BY COUNT(*) LIMIT 1


Question: How many lessons taken by customer with first name as Rylan and last name as Goodwin were completed?

Context: CREATE TABLE Lessons (customer_id VARCHAR, lesson_status_code VARCHAR); CREATE TABLE Customers (customer_id VARCHAR, first_name VARCHAR, last_name VARCHAR)

SELECT COUNT(*) FROM Lessons AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id WHERE T2.first_name = "Rylan" AND T2.last_name = "Goodwin" AND T1.lesson_status_code = "Completed"


Question: What is maximum, minimum and average amount of outstanding of customer?

Context: CREATE TABLE Customers (amount_outstanding INTEGER)

SELECT MAX(amount_outstanding), MIN(amount_outstanding), AVG(amount_outstanding) FROM Customers


Question: List the first name and last name of customers have the amount of outstanding between 1000 and 3000.

Context: CREATE TABLE Customers (first_name VARCHAR, last_name VARCHAR, amount_outstanding INTEGER)

SELECT first_name, last_name FROM Customers WHERE amount_outstanding BETWEEN 1000 AND 3000


Question: List first name and last name of customers lived in city Lockmanfurt.

Context: CREATE TABLE Customers (first_name VARCHAR, last_name VARCHAR, customer_address_id VARCHAR); CREATE TABLE Addresses (address_id VARCHAR, city VARCHAR)

SELECT T1.first_name, T1.last_name FROM Customers AS T1 JOIN Addresses AS T2 ON T1.customer_address_id = T2.address_id WHERE T2.city = "Lockmanfurt"


Question: Which country does customer with first name as Carole and last name as Bernhard lived in?

Context: CREATE TABLE Addresses (country VARCHAR, address_id VARCHAR); CREATE TABLE Customers (customer_address_id VARCHAR, first_name VARCHAR, last_name VARCHAR)

SELECT T2.country FROM Customers AS T1 JOIN Addresses AS T2 ON T1.customer_address_id = T2.address_id WHERE T1.first_name = "Carole" AND T1.last_name = "Bernhard"


Question: What is zip code of customer with first name as Carole and last name as Bernhard?

Context: CREATE TABLE Addresses (zip_postcode VARCHAR, address_id VARCHAR); CREATE TABLE Customers (customer_address_id VARCHAR, first_name VARCHAR, last_name VARCHAR)

SELECT T2.zip_postcode FROM Customers AS T1 JOIN Addresses AS T2 ON T1.customer_address_id = T2.address_id WHERE T1.first_name = "Carole" AND T1.last_name = "Bernhard"


Question: Which city does has most number of customers?

Context: CREATE TABLE Customers (customer_address_id VARCHAR); CREATE TABLE Addresses (city VARCHAR, address_id VARCHAR)

SELECT T2.city FROM Customers AS T1 JOIN Addresses AS T2 ON T1.customer_address_id = T2.address_id GROUP BY T2.city ORDER BY COUNT(*) DESC LIMIT 1


Question: How much in total does customer with first name as Carole and last name as Bernhard paid?

Context: CREATE TABLE Customers (customer_id VARCHAR, first_name VARCHAR, last_name VARCHAR); CREATE TABLE Customer_Payments (amount_payment INTEGER, customer_id VARCHAR)

SELECT SUM(T1.amount_payment) FROM Customer_Payments AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id WHERE T2.first_name = "Carole" AND T2.last_name = "Bernhard"


Question: List the number of customers that did not have any payment history.

Context: CREATE TABLE Customers (customer_id VARCHAR); CREATE TABLE Customer_Payments (customer_id VARCHAR)

SELECT COUNT(*) FROM Customers WHERE NOT customer_id IN (SELECT customer_id FROM Customer_Payments)


Question: List first name and last name of customers that have more than 2 payments.

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

SELECT T2.first_name, T2.last_name FROM Customer_Payments AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id HAVING COUNT(*) > 2


Question: List all payment methods and number of payments using each payment methods.

Context: CREATE TABLE Customer_Payments (payment_method_code VARCHAR)

SELECT payment_method_code, COUNT(*) FROM Customer_Payments GROUP BY payment_method_code


Question: How many lessons were in cancelled state?

Context: CREATE TABLE Lessons (lesson_status_code VARCHAR)

SELECT COUNT(*) FROM Lessons WHERE lesson_status_code = "Cancelled"


Question: List lesson id of all lessons taught by staff with first name as Janessa, last name as Sawayn and nickname containing letter 's'.

Context: CREATE TABLE Lessons (lesson_id VARCHAR, staff_id VARCHAR); CREATE TABLE Staff (staff_id VARCHAR, first_name VARCHAR, last_name VARCHAR)

SELECT T1.lesson_id FROM Lessons AS T1 JOIN Staff AS T2 ON T1.staff_id = T2.staff_id WHERE T2.first_name = "Janessa" AND T2.last_name = "Sawayn" AND nickname LIKE "%s%"


Question: How many lessons taught by staff whose first name has letter 'a' in it?

Context: CREATE TABLE Lessons (staff_id VARCHAR); CREATE TABLE Staff (staff_id VARCHAR, first_name VARCHAR)

SELECT COUNT(*) FROM Lessons AS T1 JOIN Staff AS T2 ON T1.staff_id = T2.staff_id WHERE T2.first_name LIKE "%a%"


Question: How long is the total lesson time taught by staff with first name as Janessa and last name as Sawayn?

Context: CREATE TABLE Lessons (staff_id VARCHAR); CREATE TABLE Staff (staff_id VARCHAR, first_name VARCHAR, last_name VARCHAR)

SELECT SUM(lesson_time) FROM Lessons AS T1 JOIN Staff AS T2 ON T1.staff_id = T2.staff_id WHERE T2.first_name = "Janessa" AND T2.last_name = "Sawayn"


Question: What is average lesson price taught by staff with first name as Janessa and last name as Sawayn?

SELECT AVG(price) FROM Lessons AS T1 JOIN Staff AS T2 ON T1.staff_id = T2.staff_id WHERE T2.first_name = "Janessa" AND T2.last_name = "Sawayn"


Question: How many lesson does customer with first name Ray took?

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

SELECT COUNT(*) FROM Lessons AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id WHERE T2.first_name = "Ray"


Question: Which last names are both used by customers and by staff?

Context: CREATE TABLE Customers (last_name VARCHAR); CREATE TABLE Staff (last_name VARCHAR)

SELECT last_name FROM Customers INTERSECT SELECT last_name FROM Staff


Question: What is the first name of the staff who did not give any lesson?

Context: CREATE TABLE Lessons (staff_id VARCHAR); CREATE TABLE Staff (first_name VARCHAR); CREATE TABLE Staff (first_name VARCHAR, staff_id VARCHAR)

SELECT first_name FROM Staff EXCEPT SELECT T2.first_name FROM Lessons AS T1 JOIN Staff AS T2 ON T1.staff_id = T2.staff_id


Question: What is the id and detail of the vehicle used in lessons for most of the times?

Context: CREATE TABLE Lessons (vehicle_id VARCHAR); CREATE TABLE Vehicles (vehicle_id VARCHAR, vehicle_details VARCHAR)

SELECT T1.vehicle_id, T1.vehicle_details FROM Vehicles AS T1 JOIN Lessons AS T2 ON T1.vehicle_id = T2.vehicle_id GROUP BY T1.vehicle_id ORDER BY COUNT(*) DESC LIMIT 1


Question: How many faculty do we have?

Context: CREATE TABLE Faculty (Id VARCHAR)


Question: What ranks do we have for faculty?

Context: CREATE TABLE Faculty (rank VARCHAR)


Question: Show all the distinct buildings that have faculty rooms.

Context: CREATE TABLE Faculty (building VARCHAR)


Question: Show the rank, first name, and last name for all the faculty.

Context: CREATE TABLE Faculty (rank VARCHAR, Fname VARCHAR, Lname VARCHAR)


Question: Show the first name, last name, and phone number for all female faculty members.

Context: CREATE TABLE Faculty (Fname VARCHAR, Lname VARCHAR, phone VARCHAR, Sex VARCHAR)

SELECT Fname, Lname, phone FROM Faculty WHERE Sex = 'F'


Question: Show ids for all the male faculty.

Context: CREATE TABLE Faculty (FacID VARCHAR, Sex VARCHAR)

SELECT FacID FROM Faculty WHERE Sex = 'M'


Question: How many female Professors do we have?

Context: CREATE TABLE Faculty (Sex VARCHAR, Rank VARCHAR)

SELECT COUNT(*) FROM Faculty WHERE Sex = 'F' AND Rank = "Professor"


Question: Show the phone, room, and building for the faculty named Jerry Prince.

Context: CREATE TABLE Faculty (phone VARCHAR, room VARCHAR, building VARCHAR, Fname VARCHAR, Lname VARCHAR)

SELECT phone, room, building FROM Faculty WHERE Fname = "Jerry" AND Lname = "Prince"


Question: How many Professors are in building NEB?

Context: CREATE TABLE Faculty (Rank VARCHAR, building VARCHAR)

SELECT COUNT(*) FROM Faculty WHERE Rank = "Professor" AND building = "NEB"


Question: Show the first name and last name for all the instructors.

Context: CREATE TABLE Faculty (fname VARCHAR, lname VARCHAR, Rank VARCHAR)

SELECT fname, lname FROM Faculty WHERE Rank = "Instructor"


Question: Show all the buildings along with the number of faculty members the buildings have.

Context: CREATE TABLE Faculty (building VARCHAR)

SELECT building, COUNT(*) FROM Faculty GROUP BY building


Question: Which building has most faculty members?

Context: CREATE TABLE Faculty (building VARCHAR)

SELECT building FROM Faculty GROUP BY building ORDER BY COUNT(*) DESC LIMIT 1


Question: Show all the buildings that have at least 10 professors.

Context: CREATE TABLE Faculty (building VARCHAR, rank VARCHAR)

SELECT building FROM Faculty WHERE rank = "Professor" GROUP BY building HAVING COUNT(*) >= 10


Question: For each faculty rank, show the number of faculty members who have it.

Context: CREATE TABLE Faculty (rank VARCHAR)

SELECT rank, COUNT(*) FROM Faculty GROUP BY rank


Question: Show all the ranks and the number of male and female faculty for each rank.

Context: CREATE TABLE Faculty (rank VARCHAR, sex VARCHAR)

SELECT rank, sex, COUNT(*) FROM Faculty GROUP BY rank, sex


Question: Which rank has the smallest number of faculty members?

Context: CREATE TABLE Faculty (rank VARCHAR)

SELECT rank FROM Faculty GROUP BY rank ORDER BY COUNT(*) LIMIT 1


Question: Show the number of male and female assistant professors.

Context: CREATE TABLE Faculty (sex VARCHAR, rank VARCHAR)

SELECT sex, COUNT(*) FROM Faculty WHERE rank = "AsstProf" GROUP BY sex


Question: What are the first name and last name of Linda Smith's advisor?

Context: CREATE TABLE Student (advisor VARCHAR, fname VARCHAR, lname VARCHAR); CREATE TABLE Faculty (fname VARCHAR, lname VARCHAR, FacID VARCHAR)

SELECT T1.fname, T1.lname FROM Faculty AS T1 JOIN Student AS T2 ON T1.FacID = T2.advisor WHERE T2.fname = "Linda" AND T2.lname = "Smith"


Question: Show the ids of students whose advisors are professors.

Context: CREATE TABLE Student (StuID VARCHAR, advisor VARCHAR); CREATE TABLE Faculty (FacID VARCHAR, rank VARCHAR)

SELECT T2.StuID FROM Faculty AS T1 JOIN Student AS T2 ON T1.FacID = T2.advisor WHERE T1.rank = "Professor"


Question: Show first name and last name for all the students advised by Michael Goodrich.

Context: CREATE TABLE Faculty (FacID VARCHAR, fname VARCHAR, lname VARCHAR); CREATE TABLE Student (fname VARCHAR, lname VARCHAR, advisor VARCHAR)

SELECT T2.fname, T2.lname FROM Faculty AS T1 JOIN Student AS T2 ON T1.FacID = T2.advisor WHERE T1.fname = "Michael" AND T1.lname = "Goodrich"


Question: Show the faculty id of each faculty member, along with the number of students he or she advises.

Context: CREATE TABLE Faculty (FacID VARCHAR); CREATE TABLE Student (advisor VARCHAR)

SELECT T1.FacID, COUNT(*) FROM Faculty AS T1 JOIN Student AS T2 ON T1.FacID = T2.advisor GROUP BY T1.FacID


Question: Show all the faculty ranks and the number of students advised by each rank.

Context: CREATE TABLE Student (advisor VARCHAR); CREATE TABLE Faculty (rank VARCHAR, FacID VARCHAR)

SELECT T1.rank, COUNT(*) FROM Faculty AS T1 JOIN Student AS T2 ON T1.FacID = T2.advisor GROUP BY T1.rank


Question: What are the first and last name of the faculty who has the most students?

Context: CREATE TABLE Student (advisor VARCHAR); CREATE TABLE Faculty (fname VARCHAR, lname VARCHAR, FacID VARCHAR)

SELECT T1.fname, T1.lname FROM Faculty AS T1 JOIN Student AS T2 ON T1.FacID = T2.advisor GROUP BY T1.FacID ORDER BY COUNT(*) DESC LIMIT 1


Question: Show the ids for all the faculty members who have at least 2 students.

SELECT T1.FacID FROM Faculty AS T1 JOIN Student AS T2 ON T1.FacID = T2.advisor GROUP BY T1.FacID HAVING COUNT(*) >= 2


Question: Show ids for the faculty members who don't advise any student.

Context: CREATE TABLE Faculty (FacID VARCHAR, advisor VARCHAR); CREATE TABLE Student (FacID VARCHAR, advisor VARCHAR)

SELECT FacID FROM Faculty EXCEPT SELECT advisor FROM Student


Question: What activities do we have?

Context: CREATE TABLE Activity (activity_name VARCHAR)


Question: How many activities do we have?

Context: CREATE TABLE Activity (Id VARCHAR)


Question: How many faculty members participate in an activity?

Context: CREATE TABLE Faculty_participates_in (FacID VARCHAR)

SELECT COUNT(DISTINCT FacID) FROM Faculty_participates_in


Question: Show the ids of the faculty who don't participate in any activity.

Context: CREATE TABLE Faculty (FacID VARCHAR); CREATE TABLE Faculty_participates_in (FacID VARCHAR)

SELECT FacID FROM Faculty EXCEPT SELECT FacID FROM Faculty_participates_in


Question: Show the ids of all the faculty members who participate in an activity and advise a student.

Context: CREATE TABLE Student (FacID VARCHAR, advisor VARCHAR); CREATE TABLE Faculty_participates_in (FacID VARCHAR, advisor VARCHAR)

SELECT FacID FROM Faculty_participates_in INTERSECT SELECT advisor FROM Student


Question: How many activities does Mark Giuliano participate in?

Context: CREATE TABLE Faculty_participates_in (facID VARCHAR); CREATE TABLE Faculty (facID VARCHAR, fname VARCHAR, lname VARCHAR)

SELECT COUNT(*) FROM Faculty AS T1 JOIN Faculty_participates_in AS T2 ON T1.facID = T2.facID WHERE T1.fname = "Mark" AND T1.lname = "Giuliano"


Question: Show the names of all the activities Mark Giuliano participates in.

Context: CREATE TABLE Activity (activity_name VARCHAR, actid VARCHAR); CREATE TABLE Faculty (facID VARCHAR, fname VARCHAR, lname VARCHAR); CREATE TABLE Faculty_participates_in (facID VARCHAR, actid VARCHAR)

SELECT T3.activity_name FROM Faculty AS T1 JOIN Faculty_participates_in AS T2 ON T1.facID = T2.facID JOIN Activity AS T3 ON T3.actid = T2.actid WHERE T1.fname = "Mark" AND T1.lname = "Giuliano"


Question: Show the first and last name of all the faculty members who participated in some activity, together with the number of activities they participated in.

Context: CREATE TABLE Faculty_participates_in (facID VARCHAR); CREATE TABLE Faculty (fname VARCHAR, lname VARCHAR, FacID VARCHAR, facID VARCHAR)

SELECT T1.fname, T1.lname, COUNT(*), T1.FacID FROM Faculty AS T1 JOIN Faculty_participates_in AS T2 ON T1.facID = T2.facID GROUP BY T1.FacID


Question: Show all the activity names and the number of faculty involved in each activity.

Context: CREATE TABLE Faculty_participates_in (actID VARCHAR); CREATE TABLE Activity (activity_name VARCHAR, actID VARCHAR)

SELECT T1.activity_name, COUNT(*) FROM Activity AS T1 JOIN Faculty_participates_in AS T2 ON T1.actID = T2.actID GROUP BY T1.actID


Question: What is the first and last name of the faculty participating in the most activities?

SELECT T1.fname, T1.lname FROM Faculty AS T1 JOIN Faculty_participates_in AS T2 ON T1.facID = T2.facID GROUP BY T1.FacID ORDER BY COUNT(*) DESC LIMIT 1


Question: What is the name of the activity that has the most faculty members involved in?

SELECT T1.activity_name FROM Activity AS T1 JOIN Faculty_participates_in AS T2 ON T1.actID = T2.actID GROUP BY T1.actID ORDER BY COUNT(*) DESC LIMIT 1


Question: Show the ids of the students who don't participate in any activity.

Context: CREATE TABLE Participates_in (StuID VARCHAR); CREATE TABLE Student (StuID VARCHAR)

SELECT StuID FROM Student EXCEPT SELECT StuID FROM Participates_in


Question: Show the ids for all the students who participate in an activity and are under 20.

Context: CREATE TABLE Student (StuID VARCHAR, age INTEGER); CREATE TABLE Participates_in (StuID VARCHAR, age INTEGER)

SELECT StuID FROM Participates_in INTERSECT SELECT StuID FROM Student WHERE age < 20


Question: What is the first and last name of the student participating in the most activities?

Context: CREATE TABLE Student (fname VARCHAR, lname VARCHAR, StuID VARCHAR); CREATE TABLE Participates_in (StuID VARCHAR)

SELECT T1.fname, T1.lname FROM Student AS T1 JOIN Participates_in AS T2 ON T1.StuID = T2.StuID GROUP BY T1.StuID ORDER BY COUNT(*) DESC LIMIT 1


Question: What is the name of the activity with the most students?

Context: CREATE TABLE Participates_in (actID VARCHAR); CREATE TABLE Activity (activity_name VARCHAR, actID VARCHAR)

SELECT T1.activity_name FROM Activity AS T1 JOIN Participates_in AS T2 ON T1.actID = T2.actID GROUP BY T1.actID ORDER BY COUNT(*) DESC LIMIT 1


Question: Find the first names of the faculty members who are playing Canoeing or Kayaking.

Context: CREATE TABLE activity (activity_name VARCHAR); CREATE TABLE Faculty_participates_in (facID VARCHAR, actid VARCHAR); CREATE TABLE Faculty (lname VARCHAR, facID VARCHAR)

SELECT DISTINCT T1.lname FROM Faculty AS T1 JOIN Faculty_participates_in AS T2 ON T1.facID = T2.facID JOIN activity AS T3 ON T2.actid = T2.actid WHERE T3.activity_name = 'Canoeing' OR T3.activity_name = 'Kayaking'


Question: Find the first names of professors who are not playing Canoeing or Kayaking.

Context: CREATE TABLE faculty (lname VARCHAR, rank VARCHAR); CREATE TABLE activity (activity_name VARCHAR); CREATE TABLE Faculty_participates_in (facID VARCHAR, actid VARCHAR); CREATE TABLE Faculty (lname VARCHAR, facID VARCHAR)

SELECT lname FROM faculty WHERE rank = 'Professor' EXCEPT SELECT DISTINCT T1.lname FROM Faculty AS T1 JOIN Faculty_participates_in AS T2 ON T1.facID = T2.facID JOIN activity AS T3 ON T2.actid = T2.actid WHERE T3.activity_name = 'Canoeing' OR T3.activity_name = 'Kayaking'


Question: Find the first names of the faculty members who participate in Canoeing and Kayaking.

SELECT T1.lname FROM Faculty AS T1 JOIN Faculty_participates_in AS T2 ON T1.facID = T2.facID JOIN activity AS T3 ON T2.actid = T2.actid WHERE T3.activity_name = 'Canoeing' INTERSECT SELECT T1.lname FROM Faculty AS T1 JOIN Faculty_participates_in AS T2 ON T1.facID = T2.facID JOIN activity AS T3 ON T2.actid = T2.actid WHERE T3.activity_name = 'Kayaking'


Question: Find the ids of the students who participate in Canoeing and Kayaking.

Context: CREATE TABLE activity (actid VARCHAR, activity_name VARCHAR); CREATE TABLE participates_in (stuid VARCHAR)

SELECT T1.stuid FROM participates_in AS T1 JOIN activity AS T2 ON T2.actid = T2.actid WHERE T2.activity_name = 'Canoeing' INTERSECT SELECT T1.stuid FROM participates_in AS T1 JOIN activity AS T2 ON T2.actid = T2.actid WHERE T2.activity_name = 'Kayaking'


Question: Find the name of the airport in the city of Goroka.

Context: CREATE TABLE airports (name VARCHAR, city VARCHAR)

SELECT name FROM airports WHERE city = 'Goroka'


Question: Find the name, city, country, and altitude (or elevation) of the airports in the city of New York.

Context: CREATE TABLE airports (name VARCHAR, city VARCHAR, country VARCHAR, elevation VARCHAR)

SELECT name, city, country, elevation FROM airports WHERE city = 'New York'


Question: How many airlines are there?

Context: CREATE TABLE airlines (Id VARCHAR)


Question: How many airlines does Russia has?

Context: CREATE TABLE airlines (country VARCHAR)

SELECT COUNT(*) FROM airlines WHERE country = 'Russia'


Question: What is the maximum elevation of all airports in the country of Iceland?

Context: CREATE TABLE airports (elevation INTEGER, country VARCHAR)

SELECT MAX(elevation) FROM airports WHERE country = 'Iceland'


Question: Find the name of the airports located in Cuba or Argentina.

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

SELECT name FROM airports WHERE country = 'Cuba' OR country = 'Argentina'


Question: Find the country of the airlines whose name starts with 'Orbit'.

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

SELECT country FROM airlines WHERE name LIKE 'Orbit%'


Question: Find the name of airports whose altitude is between -50 and 50.

Context: CREATE TABLE airports (name VARCHAR, elevation INTEGER)

SELECT name FROM airports WHERE elevation BETWEEN -50 AND 50


Question: Which country is the airport that has the highest altitude located in?

Context: CREATE TABLE airports (country VARCHAR, elevation VARCHAR)

SELECT country FROM airports ORDER BY elevation DESC LIMIT 1


Question: Find the number of airports whose name contain the word 'International'.

Context: CREATE TABLE airports (name VARCHAR)

SELECT COUNT(*) FROM airports WHERE name LIKE '%International%'


Question: How many different cities do have some airport in the country of Greenland?

Context: CREATE TABLE airports (city VARCHAR, country VARCHAR)

SELECT COUNT(DISTINCT city) FROM airports WHERE country = 'Greenland'


Question: Find the number of routes operated by American Airlines.

Context: CREATE TABLE routes (alid VARCHAR); CREATE TABLE airlines (alid VARCHAR, name VARCHAR)

SELECT COUNT(*) FROM airlines AS T1 JOIN routes AS T2 ON T1.alid = T2.alid WHERE T1.name = 'American Airlines'


Question: Find the number of routes whose destination airports are in Canada.

Context: CREATE TABLE routes (dst_apid VARCHAR); CREATE TABLE airports (apid VARCHAR)

SELECT COUNT(*) FROM airports AS T1 JOIN routes AS T2 ON T1.apid = T2.dst_apid WHERE country = 'Canada'


Question: Find the name, city, and country of the airport that has the lowest altitude.

SELECT name, city, country FROM airports ORDER BY elevation LIMIT 1


Question: Find the name, city, and country of the airport that has the highest latitude.

SELECT name, city, country FROM airports ORDER BY elevation DESC LIMIT 1


Question: Find the name and city of the airport which is the destination of the most number of routes.

Context: CREATE TABLE airports (name VARCHAR, city VARCHAR, apid VARCHAR); CREATE TABLE routes (dst_apid VARCHAR)

SELECT T1.name, T1.city, T2.dst_apid FROM airports AS T1 JOIN routes AS T2 ON T1.apid = T2.dst_apid GROUP BY T2.dst_apid ORDER BY COUNT(*) DESC LIMIT 1


Question: Find the names of the top 10 airlines that operate the most number of routes.

Context: CREATE TABLE airlines (name VARCHAR, alid VARCHAR); CREATE TABLE routes (alid VARCHAR)

SELECT T1.name, T2.alid FROM airlines AS T1 JOIN routes AS T2 ON T1.alid = T2.alid GROUP BY T2.alid ORDER BY COUNT(*) DESC LIMIT 10


Question: Find the name and city of the airport which is the source for the most number of flight routes.

Context: CREATE TABLE airports (name VARCHAR, city VARCHAR, apid VARCHAR); CREATE TABLE routes (src_apid VARCHAR)

SELECT T1.name, T1.city, T2.src_apid FROM airports AS T1 JOIN routes AS T2 ON T1.apid = T2.src_apid GROUP BY T2.src_apid ORDER BY COUNT(*) DESC LIMIT 1


Question: Find the number of different airports which are the destinations of the American Airlines.

SELECT COUNT(DISTINCT dst_apid) FROM airlines AS T1 JOIN routes AS T2 ON T1.alid = T2.alid WHERE T1.name = 'American Airlines'


Question: Which countries has the most number of airlines?

Context: CREATE TABLE airlines (country VARCHAR)

SELECT country FROM airlines GROUP BY country ORDER BY COUNT(*) DESC LIMIT 1


Question: Which countries has the most number of airlines whose active status is 'Y'?

Context: CREATE TABLE airlines (country VARCHAR, active VARCHAR)

SELECT country FROM airlines WHERE active = 'Y' GROUP BY country ORDER BY COUNT(*) DESC LIMIT 1


Question: List all countries and their number of airlines in the descending order of number of airlines.

Context: CREATE TABLE airlines (country VARCHAR)

SELECT country, COUNT(*) FROM airlines GROUP BY country ORDER BY COUNT(*) DESC


Question: How many airports are there per country? Order the countries by decreasing number of airports.

Context: CREATE TABLE airports (country VARCHAR)

SELECT COUNT(*), country FROM airports GROUP BY country ORDER BY COUNT(*) DESC


Question: How many airports are there per city in the United States? Order the cities by decreasing number of airports.

SELECT COUNT(*), city FROM airports WHERE country = 'United States' GROUP BY city ORDER BY COUNT(*) DESC


Question: Return the cities with more than 3 airports in the United States.

SELECT city FROM airports WHERE country = 'United States' GROUP BY city HAVING COUNT(*) > 3


Question: How many cities are there that have more than 3 airports?

Context: CREATE TABLE airports (city VARCHAR)

SELECT COUNT(*) FROM (SELECT city FROM airports GROUP BY city HAVING COUNT(*) > 3)


Question: List the cities which have more than one airport and number of airports.

Context: CREATE TABLE airports (city VARCHAR)

SELECT city, COUNT(*) FROM airports GROUP BY city HAVING COUNT(*) > 1


Question: List the cities which have more than 2 airports sorted by the number of airports.

Context: CREATE TABLE airports (city VARCHAR)

SELECT city FROM airports GROUP BY city HAVING COUNT(*) > 2 ORDER BY COUNT(*)


Question: Find the number of routes for each source airport and the airport name.

Context: CREATE TABLE airports (name VARCHAR, apid VARCHAR); CREATE TABLE routes (src_apid VARCHAR)

SELECT COUNT(*), T1.name FROM airports AS T1 JOIN routes AS T2 ON T1.apid = T2.src_apid GROUP BY T1.name


Question: Find the number of routes and airport name for each source airport, order the results by decreasing number of routes.

SELECT COUNT(*), T1.name FROM airports AS T1 JOIN routes AS T2 ON T1.apid = T2.src_apid GROUP BY T1.name ORDER BY COUNT(*) DESC


Question: Find the average elevation of all airports for each country.

Context: CREATE TABLE airports (country VARCHAR, elevation INTEGER)

SELECT AVG(elevation), country FROM airports GROUP BY country


Question: Find the cities which have exactly two airports.

Context: CREATE TABLE airports (city VARCHAR)

SELECT city FROM airports GROUP BY city HAVING COUNT(*) = 2


Question: For each country and airline name, how many routes are there?

Context: CREATE TABLE airlines (country VARCHAR, name VARCHAR, alid VARCHAR); CREATE TABLE routes (alid VARCHAR)

SELECT T1.country, T1.name, COUNT(*) FROM airlines AS T1 JOIN routes AS T2 ON T1.alid = T2.alid GROUP BY T1.country, T1.name


Question: Find the number of routes with destination airports in Italy.

Context: CREATE TABLE routes (dst_apid VARCHAR); CREATE TABLE airports (apid VARCHAR, country VARCHAR)

SELECT COUNT(*) FROM routes AS T1 JOIN airports AS T2 ON T1.dst_apid = T2.apid WHERE T2.country = 'Italy'


Question: Return the number of routes with destination airport in Italy operated by the airline with name 'American Airlines'.

Context: CREATE TABLE routes (dst_apid VARCHAR, alid VARCHAR); CREATE TABLE airports (apid VARCHAR, country VARCHAR); CREATE TABLE airlines (alid VARCHAR, name VARCHAR)

SELECT COUNT(*) FROM routes AS T1 JOIN airports AS T2 ON T1.dst_apid = T2.apid JOIN airlines AS T3 ON T1.alid = T3.alid WHERE T2.country = 'Italy' AND T3.name = 'American Airlines'


Question: Find the number of routes that have destination John F Kennedy International Airport.

Context: CREATE TABLE airports (apid VARCHAR, name VARCHAR); CREATE TABLE routes (dst_apid VARCHAR)

SELECT COUNT(*) FROM airports AS T1 JOIN routes AS T2 ON T1.apid = T2.dst_apid WHERE T1.name = 'John F Kennedy International Airport'


Question: Find the number of routes from the United States to Canada.

Context: CREATE TABLE airports (dst_apid VARCHAR, src_apid VARCHAR, apid VARCHAR, country VARCHAR); CREATE TABLE routes (dst_apid VARCHAR, src_apid VARCHAR, apid VARCHAR, country VARCHAR)

SELECT COUNT(*) FROM routes WHERE dst_apid IN (SELECT apid FROM airports WHERE country = 'Canada') AND src_apid IN (SELECT apid FROM airports WHERE country = 'United States')


Question: Find the id of routes whose source and destination airports are in the United States.

Context: CREATE TABLE routes (rid VARCHAR, dst_apid VARCHAR, src_apid VARCHAR, apid VARCHAR, country VARCHAR); CREATE TABLE airports (rid VARCHAR, dst_apid VARCHAR, src_apid VARCHAR, apid VARCHAR, country VARCHAR)

SELECT rid FROM routes WHERE dst_apid IN (SELECT apid FROM airports WHERE country = 'United States') AND src_apid IN (SELECT apid FROM airports WHERE country = 'United States')


Question: Find the name of airline which runs the most number of routes.

SELECT T1.name FROM airlines AS T1 JOIN routes AS T2 ON T1.alid = T2.alid GROUP BY T1.name ORDER BY COUNT(*) DESC LIMIT 1


Question: Find the busiest source airport that runs most number of routes in China.

Context: CREATE TABLE routes (src_apid VARCHAR); CREATE TABLE airports (name VARCHAR, apid VARCHAR, country VARCHAR)

SELECT T1.name FROM airports AS T1 JOIN routes AS T2 ON T1.apid = T2.src_apid WHERE T1.country = 'China' GROUP BY T1.name ORDER BY COUNT(*) DESC LIMIT 1


Question: Find the busiest destination airport that runs most number of routes in China.

Context: CREATE TABLE routes (dst_apid VARCHAR); CREATE TABLE airports (name VARCHAR, apid VARCHAR, country VARCHAR)

SELECT T1.name FROM airports AS T1 JOIN routes AS T2 ON T1.apid = T2.dst_apid WHERE T1.country = 'China' GROUP BY T1.name ORDER BY COUNT(*) DESC LIMIT 1