database_id
stringlengths
4
31
query
stringlengths
22
577
question
stringlengths
19
224
train_station
SELECT name , TIME , service FROM train
Show the name, time, and service for all trains.
train_station
SELECT count(*) FROM train
Show the number of trains
train_station
SELECT name , service FROM train ORDER BY TIME
Show the name and service for all trains in order by time.
train_station
SELECT T2.name , count(*) FROM train_station AS T1 JOIN station AS T2 ON T1.station_id = T2.station_id GROUP BY T1.station_id
Show the station name and number of trains in each station.
train_station
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
show the train name and station name for each train.
train_station
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
Show all train names and times in stations in London in descending order by train time.
train_station
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
Show the station name with greatest number of trains.
train_station
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
Show the station name with at least two trains.
train_station
SELECT LOCATION FROM station GROUP BY LOCATION HAVING count(*) = 1
Show all locations with only 1 station.
train_station
SELECT name FROM station WHERE station_id NOT IN (SELECT station_id FROM train_station)
Show station names without any trains.
train_station
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 =...
What are the names of the stations which serve both "Ananthapuri Express" and "Guruvayur Express" trains?
train_station
SELECT T2.name FROM train_station AS T1 JOIN train AS T2 ON T1.train_id = T2.train_id WHERE T1.station_id NOT IN (SELECT T4.station_id FROM train_station AS T3 JOIN station AS T4 ON T3.station_id = T4.station_id WHERE t4.location = "London")
Find the names of the trains that do not pass any station located in London.
club_1
SELECT t3.Lname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t1.clubName = "Bootup Baltimore"
Find the last names of the members of the club "Bootup Baltimore".
club_1
SELECT t3.lname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t1.clubname = "Hopkins Student Enterprises"
Who are the members of the club named "Hopkins Student Enterprises"? Show the last name.
club_1
SELECT count(*) FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t1.clubname = "Tennis Club"
How many members does the club "Tennis Club" has?
club_1
SELECT count(*) FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t1.clubname = "Pen and Paper Gaming"
Find the number of members of club "Pen and Paper Gaming".
club_1
SELECT count(*) FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t3.fname = "Linda" AND t3.lname = "Smith"
How many clubs does "Linda Smith" belong to?
club_1
SELECT count(*) FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t3.fname = "Tracy" AND t3.lname = "Kim"
Find the number of clubs where "Tracy Kim" is a member.
club_1
SELECT t3.fname , t3.lname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t1.clubname = "Bootup Baltimore" AND t3.sex = "F"
Find all the female members of club "Bootup Baltimore". Show the first name and last name.
club_1
SELECT t3.fname , t3.lname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t1.clubname = "Hopkins Student Enterprises" AND t3.sex = "M"
Find all the male members of club "Hopkins Student Enterprises". Show the first name and last name.
club_1
SELECT t3.fname , t3.lname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t1.clubname = "Bootup Baltimore" AND t3.major = "600"
Find all members of "Bootup Baltimore" whose major is "600". Show the first name and last name.
club_1
SELECT t1.clubname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t3.major = "600" GROUP BY t1.clubname ORDER BY count(*) DESC LIMIT 1
Which club has the most members majoring in "600"?
club_1
SELECT t1.clubname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t3.sex = "F" GROUP BY t1.clubname ORDER BY count(*) DESC LIMIT 1
Find the name of the club that has the most female students.
club_1
SELECT t3.fname , t3.lname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t1.clubname = "Bootup Baltimore" AND t2.position = "President"
What are the first and last name of the president of the club "Bootup Baltimore"?
club_1
SELECT t3.fname , t3.lname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t1.clubname = "Hopkins Student Enterprises" AND t2.position = "CTO"
Who is the "CTO" of club "Hopkins Student Enterprises"? Show the first name and last name.
club_1
SELECT count(DISTINCT t2.position) FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid WHERE t1.clubname = "Bootup Baltimore"
How many different roles are there in the club "Bootup Baltimore"?
club_1
SELECT count(*) FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t1.clubname = "Bootup Baltimore" AND t3.age > 18
How many members of "Bootup Baltimore" are older than 18?
club_1
SELECT count(*) FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t1.clubname = "Bootup Baltimore" AND t3.age < 18
How many members of club "Bootup Baltimore" are younger than 18?
club_1
SELECT DISTINCT t1.clubname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t3.city_code = "BAL"
Find the names of all the clubs that have at least a member from the city with city code "BAL".
club_1
SELECT DISTINCT t1.clubname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t3.city_code = "HOU"
Find the names of the clubs that have at least a member from the city with city code "HOU".
club_1
SELECT count(DISTINCT t1.clubname) FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t3.fname = "Eric" AND t3.lname = "Tai"
How many clubs does the student named "Eric Tai" belong to?
club_1
SELECT DISTINCT t1.clubname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t3.fname = "Davis" AND t3.lname = "Steven"
List the clubs having "Davis Steven" as a member.
club_1
SELECT DISTINCT t1.clubname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t3.advisor = 1121
List the clubs that have at least a member with advisor "1121".
club_1
SELECT avg(t3.age) FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t1.clubname = "Bootup Baltimore"
What is the average age of the members of the club "Bootup Baltimore"?
club_1
SELECT avg(t3.age) FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t1.clubname = "Hopkins Student Enterprises"
Find the average age of members of the club "Hopkins Student Enterprises".
wedding
SELECT count(*) FROM Church WHERE Open_Date < 1850
How many churches opened before 1850 are there?
wedding
SELECT name , open_date , organized_by FROM Church
Show the name, open date, and organizer for all churches.
wedding
SELECT name FROM church ORDER BY open_date DESC
List all church names in descending order of opening date.
wedding
SELECT open_date FROM church GROUP BY open_date HAVING count(*) >= 2
Show the opening year in which at least two churches opened.
wedding
SELECT organized_by , name FROM church WHERE open_date BETWEEN 1830 AND 1840
Show the organizer and name for churches that opened between 1830 and 1840.
wedding
SELECT open_date , count(*) FROM church GROUP BY open_date
Show all opening years and the number of churches that opened in that year.
wedding
SELECT name , open_date FROM church ORDER BY open_date DESC LIMIT 3
Show the name and opening year for three churches that opened most recently.
wedding
SELECT count(*) FROM people WHERE is_male = 'F' AND age > 30
How many female people are older than 30 in our record?
wedding
SELECT country FROM people WHERE age < 25 INTERSECT SELECT country FROM people WHERE age > 30
Show the country where people older than 30 and younger than 25 are from.
wedding
SELECT min(age) , max(age) , avg(age) FROM people
Show the minimum, maximum, and average age for all people.
wedding
SELECT name , country FROM people WHERE age < (SELECT avg(age) FROM people)
Show the name and country for all people whose age is smaller than the average.
wedding
SELECT T2.name , T3.name FROM wedding AS T1 JOIN people AS T2 ON T1.male_id = T2.people_id JOIN people AS T3 ON T1.female_id = T3.people_id WHERE T1.year > 2014
Show the pair of male and female names in all weddings after year 2014
wedding
SELECT name , age FROM people WHERE is_male = 'T' AND people_id NOT IN (SELECT male_id FROM wedding)
Show the name and age for all male people who don't have a wedding.
wedding
SELECT name FROM church EXCEPT SELECT T1.name FROM church AS T1 JOIN wedding AS T2 ON T1.church_id = T2.church_id WHERE T2.year = 2015
Show all church names except for those that had a wedding in year 2015.
wedding
SELECT T1.name FROM church AS T1 JOIN wedding AS T2 ON T1.church_id = T2.church_id GROUP BY T1.church_id HAVING count(*) >= 2
Show all church names that have hosted least two weddings.
wedding
SELECT T2.name FROM wedding AS T1 JOIN people AS T2 ON T1.female_id = T2.people_id WHERE T1.year = 2016 AND T2.is_male = 'F' AND T2.country = 'Canada'
Show the names for all females from Canada having a wedding in year 2016.
wedding
SELECT count(*) FROM wedding WHERE YEAR = 2016
How many weddings are there in year 2016?
wedding
SELECT T4.name FROM wedding AS T1 JOIN people AS T2 ON T1.male_id = T2.people_id JOIN people AS T3 ON T1.female_id = T3.people_id JOIN church AS T4 ON T4.church_id = T1.church_id WHERE T2.age > 30 OR T3.age > 30
Show the church names for the weddings of all people older than 30.
wedding
SELECT country , count(*) FROM people GROUP BY country
Show all countries and the number of people from each country.
debate
SELECT Name FROM people WHERE Age = 35 OR Age = 36
Show the names of people aged either 35 or 36.
debate
SELECT Party FROM people ORDER BY Age ASC LIMIT 1
What is the party of the youngest people?
debate
SELECT Party FROM people GROUP BY Party ORDER BY COUNT(*) DESC LIMIT 1
Show the party that has the most people.
debate
SELECT T3.Name , T2.Date , T2.Venue FROM debate_people AS T1 JOIN debate AS T2 ON T1.Debate_ID = T2.Debate_ID JOIN people AS T3 ON T1.Affirmative = T3.People_ID
Show the names of people, and dates and venues of debates they are on the affirmative side.
debate
SELECT T3.Name , T2.Date , T2.Venue FROM debate_people AS T1 JOIN debate AS T2 ON T1.Debate_ID = T2.Debate_ID JOIN people AS T3 ON T1.Negative = T3.People_ID ORDER BY T3.Name ASC
Show the names of people, and dates and venues of debates they are on the negative side, ordered in ascending alphabetical order of name.
debate
SELECT T3.Name FROM debate_people AS T1 JOIN debate AS T2 ON T1.Debate_ID = T2.Debate_ID JOIN people AS T3 ON T1.Affirmative = T3.People_ID WHERE T2.Num_of_Audience > 200
Show the names of people that are on affirmative side of debates with number of audience bigger than 200.
debate
SELECT T2.Name , COUNT(*) FROM debate_people AS T1 JOIN people AS T2 ON T1.Affirmative = T2.People_ID GROUP BY T2.Name
Show the names of people and the number of times they have been on the affirmative side of debates.
debate
SELECT T2.Name FROM debate_people AS T1 JOIN people AS T2 ON T1.Negative = T2.People_ID GROUP BY T2.Name HAVING COUNT(*) >= 2
Show the names of people who have been on the negative side of debates at least twice.
flight_company
SELECT DISTINCT T1.type FROM operate_company AS T1 JOIN flight AS t2 ON T1.id = T2.company_id WHERE T2.velocity < 200
What are the distinct types of the companies that have operated any flights with velocity less than 200?
flight_company
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
What are the ids and names of the companies that operated more than one flight?
flight_company
SELECT T1.id, T1.name, T1.IATA FROM airport as t1 JOIN flight AS t2 ON t1.id = t2.airport_id GROUP BY t1.id ORDER BY count(*) DESC LIMIT 1
What is the id, name and IATA code of the airport that had most number of flights?
flight_company
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'
What are the different pilot names who had piloted a flight in the country 'United States' or in the airport named 'Billund Airport'?
flight_company
SELECT TYPE , count(*) FROM operate_company GROUP BY TYPE ORDER BY count(*) DESC LIMIT 1
What is the most common company type, and how many are there?
flight_company
SELECT count(*) FROM airport WHERE id NOT IN ( SELECT airport_id FROM flight WHERE pilot = 'Thompson' );
How many airports haven't the pilot 'Thompson' driven an aircraft?
flight_company
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'
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.
flight_company
SELECT name FROM airport WHERE name LIKE '%international%'
Which of the airport names contains the word 'international'?
flight_company
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
How many companies operates airlines in each airport?
flight_company
SELECT country FROM airport GROUP BY country HAVING count(*) > 2
which countries have more than 2 airports?
election
SELECT count(*) FROM county
How many counties are there in total?
election
SELECT County_name , Population FROM county
Show the county name and population of all counties.
election
SELECT avg(Population) FROM county
Show the average population of all counties.
election
SELECT max(Population) , min(Population) FROM county
Return the maximum and minimum population among all counties.
election
SELECT DISTINCT District FROM election
Show all the distinct districts for elections.
election
SELECT Zip_code FROM county WHERE County_name = "Howard"
Show the zip code of the county with name "Howard".
election
SELECT Delegate FROM election WHERE District = 1
Show the delegate from district 1 in election.
election
SELECT Delegate , Committee FROM election
Show the delegate and committee information of elections.
election
SELECT count(DISTINCT Governor) FROM party
How many distinct governors are there?
election
SELECT Lieutenant_Governor , Comptroller FROM party WHERE Party = "Democratic"
Show the lieutenant governor and comptroller from the democratic party.
election
SELECT DISTINCT YEAR FROM party WHERE Governor = "Eliot Spitzer"
In which distinct years was the governor "Eliot Spitzer"?
election
SELECT * FROM election
Show all the information about election.
election
SELECT T2.Delegate , T1.County_name FROM county AS T1 JOIN election AS T2 ON T1.County_id = T2.District
Show the delegates and the names of county they belong to.
election
SELECT T2.Delegate FROM county AS T1 JOIN election AS T2 ON T1.County_id = T2.District WHERE T1.Population < 100000
Which delegates are from counties with population smaller than 100000?
election
SELECT count(DISTINCT T2.Delegate) FROM county AS T1 JOIN election AS T2 ON T1.County_id = T2.District WHERE T1.Population > 50000
How many distinct delegates are from counties with population larger than 50000?
election
SELECT T1.County_name FROM county AS T1 JOIN election AS T2 ON T1.County_id = T2.District WHERE T2.Committee = "Appropriations"
What are the names of the county that the delegates on "Appropriations" committee belong to?
election
SELECT T1.Delegate , T2.Party FROM election AS T1 JOIN party AS T2 ON T1.Party = T2.Party_ID
Show the delegates and the names of the party they belong to.
election
SELECT T2.Governor FROM election AS T1 JOIN party AS T2 ON T1.Party = T2.Party_ID WHERE T1.District = 1
Who were the governors of the parties associated with delegates from district 1?
election
SELECT T2.Comptroller FROM election AS T1 JOIN party AS T2 ON T1.Party = T2.Party_ID WHERE T1.District = 1 OR T1.District = 2
Who were the comptrollers of the parties associated with the delegates from district 1 or district 2?
election
SELECT T1.Committee FROM election AS T1 JOIN party AS T2 ON T1.Party = T2.Party_ID WHERE T2.Party = "Democratic"
Return all the committees that have delegates from Democratic party.
election
SELECT T1.County_name , COUNT(*) FROM county AS T1 JOIN election AS T2 ON T1.County_id = T2.District GROUP BY T1.County_id
Show the name of each county along with the corresponding number of delegates from that county.
election
SELECT T2.Party , COUNT(*) FROM election AS T1 JOIN party AS T2 ON T1.Party = T2.Party_ID GROUP BY T1.Party
Show the name of each party and the corresponding number of delegates from that party.
election
SELECT County_name FROM county ORDER BY Population ASC
Return the names of all counties sorted by population in ascending order.
election
SELECT County_name FROM county ORDER BY County_name DESC
Return the names of all counties sorted by county name in descending alphabetical order.
election
SELECT County_name FROM county ORDER BY Population DESC LIMIT 1
Show the name of the county with the biggest population.
election
SELECT County_name FROM county ORDER BY Population ASC LIMIT 3
Show the 3 counties with the smallest population.
election
SELECT T1.County_name FROM county AS T1 JOIN election AS T2 ON T1.County_id = T2.District GROUP BY T1.County_id HAVING COUNT(*) >= 2
Show the names of counties that have at least two delegates.
election
SELECT Party FROM party GROUP BY Party HAVING COUNT(*) >= 2
Show the name of the party that has at least two records.