database_id
stringlengths
4
31
query
stringlengths
22
577
question
stringlengths
19
224
election
SELECT T2.Party FROM election AS T1 JOIN party AS T2 ON T1.Party = T2.Party_ID GROUP BY T1.Party ORDER BY COUNT(*) DESC LIMIT 1
Show the name of the party that has the most delegates.
election
SELECT Governor FROM party GROUP BY Governor ORDER BY COUNT(*) DESC LIMIT 1
Show the people that have been governor the most times.
election
SELECT Comptroller , COUNT(*) FROM party GROUP BY Comptroller ORDER BY COUNT(*) DESC LIMIT 1
Show the people that have been comptroller the most times and the corresponding number of times.
election
SELECT Party FROM party WHERE Party_ID NOT IN (SELECT Party FROM election)
What are the names of parties that do not have delegates in election?
election
SELECT T2.Party FROM election AS T1 JOIN party AS T2 ON T1.Party = T2.Party_ID WHERE T1.Committee = "Appropriations" INTERSECT SELECT T2.Party FROM election AS T1 JOIN party AS T2 ON T1.Party = T2.Party_ID WHERE T1.Committee = "Economic Matters"
What are the names of parties that have both delegates on "Appropriations" committee and "Economic Matters" committee
loan_1
SELECT T1.cust_name FROM customer AS T1 JOIN loan AS T2 ON T1.cust_id = T2.cust_id GROUP BY T1.cust_name ORDER BY sum(T2.amount)
List the name of all different customers who have an loan sorted by their total loan amount.
loan_1
SELECT cust_name , acc_bal FROM customer WHERE cust_name LIKE '%a%'
Find the name and account balance of the customer whose name includes the letter ‘a’.
loan_1
SELECT sum(acc_bal) FROM customer WHERE state = 'Utah' OR state = 'Texas'
Find the total account balance of each customer from Utah or Texas.
loan_1
SELECT cust_name FROM customer WHERE acc_type = 'saving' INTERSECT SELECT cust_name FROM customer WHERE acc_type = 'checking'
Find the name of customers who have both saving and checking account types.
loan_1
SELECT cust_name FROM customer EXCEPT SELECT cust_name FROM customer WHERE acc_type = 'saving'
Find the name of customers who do not have a saving account.
loan_1
SELECT cust_name FROM customer EXCEPT SELECT T1.cust_name FROM customer AS T1 JOIN loan AS T2 ON T1.cust_id = T2.cust_id WHERE T2.loan_type = 'Mortgages'
Find the name of customers who do not have a loan with a type of Mortgages.
loan_1
SELECT T1.cust_name FROM customer AS T1 JOIN loan AS T2 ON T1.cust_id = T2.cust_id WHERE loan_type = 'Mortgages' INTERSECT SELECT T1.cust_name FROM customer AS T1 JOIN loan AS T2 ON T1.cust_id = T2.cust_id WHERE loan_type = 'Auto'
Find the name of customers who have loans of both Mortgages and Auto.
loan_1
SELECT cust_name FROM customer WHERE credit_score < (SELECT avg(credit_score) FROM customer)
Find the name of customers whose credit score is below the average credit scores of all customers.
loan_1
SELECT bname FROM bank ORDER BY no_of_customers DESC LIMIT 1
Find the branch name of the bank that has the most number of customers.
loan_1
SELECT cust_name FROM customer ORDER BY credit_score LIMIT 1
Find the name of customer who has the lowest credit score.
loan_1
SELECT cust_name , acc_type , acc_bal FROM customer ORDER BY credit_score DESC LIMIT 1
Find the name, account type, and account balance of the customer who has the highest credit score.
loan_1
SELECT T1.cust_name FROM customer AS T1 JOIN loan AS T2 ON T1.cust_id = T2.cust_id GROUP BY T1.cust_name ORDER BY sum(T2.amount) DESC LIMIT 1
Find the name of customer who has the highest amount of loans.
loan_1
SELECT state FROM bank GROUP BY state ORDER BY sum(no_of_customers) DESC LIMIT 1
Find the state which has the most number of customers.
loan_1
SELECT avg(acc_bal) , acc_type FROM customer WHERE credit_score < 50 GROUP BY acc_type
For each account type, find the average account balance of customers with credit score lower than 50.
loan_1
SELECT sum(acc_bal) , state FROM customer WHERE credit_score > 100 GROUP BY state
For each state, find the total account balance of customers whose credit score is above 100.
loan_1
SELECT sum(amount) , T1.bname FROM bank AS T1 JOIN loan AS T2 ON T1.branch_id = T2.branch_id GROUP BY T1.bname
Find the total amount of loans offered by each bank branch.
loan_1
SELECT T1.cust_name FROM customer AS T1 JOIN loan AS T2 ON T1.cust_id = T2.cust_id GROUP BY T1.cust_name HAVING count(*) > 1
Find the name of customers who have more than one loan.
loan_1
SELECT T1.cust_name , T1.acc_type FROM customer AS T1 JOIN loan AS T2 ON T1.cust_id = T2.cust_id GROUP BY T1.cust_name HAVING sum(T2.amount) > 5000
Find the name and account balance of the customers who have loans with a total amount of more than 5000.
loan_1
SELECT T1.bname FROM bank AS T1 JOIN loan AS T2 ON T1.branch_id = T2.branch_id GROUP BY T1.bname ORDER BY sum(T2.amount) DESC LIMIT 1
Find the name of bank branch that provided the greatest total amount of loans.
loan_1
SELECT T2.bname FROM loan AS T1 JOIN bank AS T2 ON T1.branch_id = T2.branch_id JOIN customer AS T3 ON T1.cust_id = T3.cust_id WHERE T3.credit_score < 100 GROUP BY T2.bname ORDER BY sum(T1.amount) DESC LIMIT 1
Find the name of bank branch that provided the greatest total amount of loans to customers with credit score is less than 100.
loan_1
SELECT T1.cust_name FROM customer AS T1 JOIN loan AS T2 ON T1.cust_id = T2.cust_id WHERE amount > 3000
Find the the name of the customers who have a loan with amount more than 3000.
loan_1
SELECT T1.bname, T1.city FROM bank AS T1 JOIN loan AS T2 ON T1.branch_id = T2.branch_id WHERE T2.loan_type = 'Business'
Find the city and name of bank branches that provide business loans.
loan_1
SELECT T2.bname FROM loan AS T1 JOIN bank AS T2 ON T1.branch_id = T2.branch_id JOIN customer AS T3 ON T1.cust_id = T3.cust_id WHERE T3.credit_score < 100
Find the names of bank branches that have provided a loan to any customer whose credit score is below 100.
loan_1
SELECT sum(T2.amount) FROM bank AS T1 JOIN loan AS T2 ON T1.branch_id = T2.branch_id WHERE T1.state = 'New York'
Find the total amount of loans provided by bank branches in the state of New York.
loan_1
SELECT avg(credit_score) FROM customer WHERE cust_id IN (SELECT cust_id FROM loan)
Find the average credit score of the customers who have some loan.
flight_1
SELECT count(*) FROM Aircraft
How many aircrafts do we have?
flight_1
SELECT name , distance FROM Aircraft
Show name and distance for all aircrafts.
flight_1
SELECT aid FROM Aircraft WHERE distance > 1000
Show ids for all aircrafts with more than 1000 distance.
flight_1
SELECT count(*) FROM Aircraft WHERE distance BETWEEN 1000 AND 5000
How many aircrafts have distance between 1000 and 5000?
flight_1
SELECT name , distance FROM Aircraft WHERE aid = 12
What is the name and distance for aircraft with id 12?
flight_1
SELECT min(distance) , avg(distance) , max(distance) FROM Aircraft
What is the minimum, average, and maximum distance of all aircrafts.
flight_1
SELECT aid , name FROM Aircraft ORDER BY distance DESC LIMIT 1
Show the id and name of the aircraft with the maximum distance.
flight_1
SELECT name FROM Aircraft ORDER BY distance LIMIT 3
Show the name of aircrafts with top three lowest distances.
flight_1
SELECT name FROM Aircraft WHERE distance > (SELECT avg(distance) FROM Aircraft)
Show names for all aircrafts with distances more than the average.
flight_1
SELECT count(*) FROM Employee
How many employees do we have?
flight_1
SELECT name , salary FROM Employee ORDER BY salary
Show name and salary for all employees sorted by salary.
flight_1
SELECT eid FROM Employee WHERE salary > 100000
Show ids for all employees with at least 100000 salary.
flight_1
SELECT count(*) FROM Employee WHERE salary BETWEEN 100000 AND 200000
How many employees have salary between 100000 and 200000?
flight_1
SELECT name , salary FROM Employee WHERE eid = 242518965
What is the name and salary for employee with id 242518965?
flight_1
SELECT avg(salary) , max(salary) FROM Employee
What is average and maximum salary of all employees.
flight_1
SELECT eid , name FROM Employee ORDER BY salary DESC LIMIT 1
Show the id and name of the employee with maximum salary.
flight_1
SELECT name FROM Employee ORDER BY salary ASC LIMIT 3
Show the name of employees with three lowest salaries.
flight_1
SELECT name FROM Employee WHERE salary > (SELECT avg(salary) FROM Employee)
Show names for all employees with salary more than the average.
flight_1
SELECT eid , salary FROM Employee WHERE name = 'Mark Young'
Show the id and salary of Mark Young.
flight_1
SELECT count(*) FROM Flight
How many flights do we have?
flight_1
SELECT flno , origin , destination FROM Flight ORDER BY origin
Show flight number, origin, destination of all flights in the alphabetical order of the departure cities.
flight_1
SELECT flno FROM Flight WHERE origin = "Los Angeles"
Show all flight number from Los Angeles.
flight_1
SELECT origin FROM Flight WHERE destination = "Honolulu"
Show origins of all flights with destination Honolulu.
flight_1
SELECT departure_date , arrival_date FROM Flight WHERE origin = "Los Angeles" AND destination = "Honolulu"
Show me the departure date and arrival date for all flights from Los Angeles to Honolulu.
flight_1
SELECT flno FROM Flight WHERE distance > 2000
Show flight number for all flights with more than 2000 distance.
flight_1
SELECT avg(price) FROM Flight WHERE origin = "Los Angeles" AND destination = "Honolulu"
What is the average price for flights from Los Angeles to Honolulu.
flight_1
SELECT origin , destination FROM Flight WHERE price > 300
Show origin and destination for flights with price higher than 300.
flight_1
SELECT flno , distance FROM Flight ORDER BY price DESC LIMIT 1
Show the flight number and distance of the flight with maximum price.
flight_1
SELECT flno FROM Flight ORDER BY distance ASC LIMIT 3
Show the flight number of flights with three lowest distances.
flight_1
SELECT avg(distance) , avg(price) FROM Flight WHERE origin = "Los Angeles"
What is the average distance and average price for flights from Los Angeles.
flight_1
SELECT origin , count(*) FROM Flight GROUP BY origin
Show all origins and the number of flights from each origin.
flight_1
SELECT destination , count(*) FROM Flight GROUP BY destination
Show all destinations and the number of flights to each destination.
flight_1
SELECT origin FROM Flight GROUP BY origin ORDER BY count(*) DESC LIMIT 1
Which origin has most number of flights?
flight_1
SELECT destination FROM Flight GROUP BY destination ORDER BY count(*) LIMIT 1
Which destination has least number of flights?
flight_1
SELECT T2.name FROM Flight AS T1 JOIN Aircraft AS T2 ON T1.aid = T2.aid WHERE T1.flno = 99
What is the aircraft name for the flight with number 99
flight_1
SELECT T1.flno FROM Flight AS T1 JOIN Aircraft AS T2 ON T1.aid = T2.aid WHERE T2.name = "Airbus A340-300"
Show all flight numbers with aircraft Airbus A340-300.
flight_1
SELECT T2.name , count(*) FROM Flight AS T1 JOIN Aircraft AS T2 ON T1.aid = T2.aid GROUP BY T1.aid
Show aircraft names and number of flights for each aircraft.
flight_1
SELECT T2.name FROM Flight AS T1 JOIN Aircraft AS T2 ON T1.aid = T2.aid GROUP BY T1.aid HAVING count(*) >= 2
Show names for all aircraft with at least two flights.
flight_1
SELECT count(DISTINCT eid) FROM Certificate
How many employees have certificate.
flight_1
SELECT eid FROM Employee EXCEPT SELECT eid FROM Certificate
Show ids for all employees who do not have a certificate.
flight_1
SELECT T3.name FROM Employee AS T1 JOIN Certificate AS T2 ON T1.eid = T2.eid JOIN Aircraft AS T3 ON T3.aid = T2.aid WHERE T1.name = "John Williams"
Show names for all aircrafts of which John Williams has certificates.
flight_1
SELECT T1.name FROM Employee AS T1 JOIN Certificate AS T2 ON T1.eid = T2.eid JOIN Aircraft AS T3 ON T3.aid = T2.aid WHERE T3.name = "Boeing 737-800"
Show names for all employees who have certificate of Boeing 737-800.
flight_1
SELECT T1.name FROM Employee AS T1 JOIN Certificate AS T2 ON T1.eid = T2.eid JOIN Aircraft AS T3 ON T3.aid = T2.aid WHERE T3.name = "Boeing 737-800" INTERSECT SELECT T1.name FROM Employee AS T1 JOIN Certificate AS T2 ON T1.eid = T2.eid JOIN Aircraft AS T3 ON T3.aid = T2.aid WHERE T3.name = "Airbus A340-300"
Show names for all employees who have certificates on both Boeing 737-800 and Airbus A340-300.
flight_1
SELECT name FROM Employee EXCEPT SELECT T1.name FROM Employee AS T1 JOIN Certificate AS T2 ON T1.eid = T2.eid JOIN Aircraft AS T3 ON T3.aid = T2.aid WHERE T3.name = "Boeing 737-800"
Show names for all employees who do not have certificate of Boeing 737-800.
flight_1
SELECT T2.name FROM Certificate AS T1 JOIN Aircraft AS T2 ON T2.aid = T1.aid GROUP BY T1.aid ORDER BY count(*) LIMIT 1
Show the name of aircraft which fewest people have its certificate.
flight_1
SELECT T2.name, T2.distance FROM Certificate AS T1 JOIN Aircraft AS T2 ON T2.aid = T1.aid WHERE T2.distance > 5000 GROUP BY T1.aid ORDER BY count(*) >= 5
Show the name and distance of the aircrafts with more than 5000 distance and which at least 5 people have its certificate.
flight_1
SELECT T1.name , T1.salary FROM Employee AS T1 JOIN Certificate AS T2 ON T1.eid = T2.eid GROUP BY T1.eid ORDER BY count(*) DESC LIMIT 1
what is the salary and name of the employee who has the most number of aircraft certificates?
party_people
SELECT minister FROM party WHERE took_office > 1961 OR took_office < 1959
Show the minister who took office after 1961 or before 1959.
party_people
SELECT minister FROM party ORDER BY left_office DESC LIMIT 1
Return the minister who left office at the latest time.
party_people
SELECT T2.party_name , count(*) FROM Member AS T1 JOIN party AS T2 ON T1.party_id = T2.party_id GROUP BY T1.party_id
Show all party names and the number of members in each party.
party_people
SELECT T2.party_name FROM Member AS T1 JOIN party AS T2 ON T1.party_id = T2.party_id GROUP BY T1.party_id ORDER BY count(*) DESC LIMIT 1
What is the name of party with most number of members?
party_people
SELECT party_name FROM party WHERE party_id NOT IN (SELECT party_id FROM Member)
Show names of parties that does not have any members.
party_people
SELECT member_name FROM member WHERE party_id = 3 INTERSECT SELECT member_name FROM member WHERE party_id = 1
Show the member names which are in both the party with id 3 and the party with id 1.
party_people
SELECT T1.member_name FROM Member AS T1 JOIN party AS T2 ON T1.party_id = T2.party_id WHERE T2.Party_name != "Progress Party"
Show member names that are not in the Progress Party.
party_people
SELECT T2.party_name , count(*) FROM party_events AS T1 JOIN party AS T2 ON T1.party_id = T2.party_id GROUP BY T1.party_id
Show party names and the number of events for each party.
party_people
SELECT member_name FROM member EXCEPT SELECT T1.member_name FROM member AS T1 JOIN party_events AS T2 ON T1.member_id = T2.member_in_charge_id
Show all member names who are not in charge of any event.
party_people
SELECT T2.party_name FROM party_events AS T1 JOIN party AS T2 ON T1.party_id = T2.party_id GROUP BY T1.party_id HAVING count(*) >= 2
What are the names of parties with at least 2 events?
party_people
SELECT T1.member_name FROM member AS T1 JOIN party_events AS T2 ON T1.member_id = T2.member_in_charge_id GROUP BY T2.member_in_charge_id ORDER BY count(*) DESC LIMIT 1
What is the name of member in charge of greatest number of events?
party_people
SELECT event_name FROM party_events GROUP BY event_name HAVING count(*) > 2
find the event names that have more than 2 records.
architecture
SELECT name , nationality , id FROM architect WHERE gender = 'male' ORDER BY name
List the name, nationality and id of all male architects ordered by their names lexicographically.
architecture
SELECT DISTINCT T1.type FROM mill AS T1 JOIN architect AS t2 ON T1.architect_id = T2.id WHERE T2.nationality = 'American' OR T2.nationality = 'Canadian'
What are the distinct types of mills that are built by American or Canadian architects?
architecture
SELECT T1.id , T1.name FROM architect AS T1 JOIN bridge AS T2 ON T1.id = T2.architect_id GROUP BY T1.id HAVING count(*) >= 3
What are the ids and names of the architects who built at least 3 bridges ?
architecture
SELECT T1.id , T1.name , T1.nationality FROM architect AS T1 JOIN mill AS T2 ON T1.id = T2.architect_id GROUP BY T1.id ORDER BY count(*) DESC LIMIT 1
What is the id, name and nationality of the architect who built most mills?
architecture
SELECT T1.id , T1.name , T1.gender FROM architect AS T1 JOIN bridge AS T2 ON T1.id = T2.architect_id GROUP BY T1.id HAVING count(*) = 2 UNION SELECT T1.id , T1.name , T1.gender FROM architect AS T1 JOIN mill AS T2 ON T1.id = T2.architect_id GROUP BY T1.id HAVING count(*) = 1
What are the ids, names and genders of the architects who built two bridges or one mill?
architecture
SELECT LOCATION FROM bridge WHERE name = 'Kolob Arch' OR name = 'Rainbow Bridge'
What is the location of the bridge named 'Kolob Arch' or 'Rainbow Bridge'?
architecture
SELECT name FROM mill WHERE name LIKE '%Moulin%'
Which of the mill names contains the french word 'Moulin'?
architecture
SELECT DISTINCT T1.name FROM mill AS T1 JOIN architect AS t2 ON T1.architect_id = T2.id JOIN bridge AS T3 ON T3.architect_id = T2.id WHERE T3.length_meters > 80
What are the distinct name of the mills built by the architects who have also built a bridge longer than 80 meters?
architecture
SELECT TYPE , count(*) FROM mill GROUP BY TYPE ORDER BY count(*) DESC LIMIT 1
What is the most common mill type, and how many are there?
architecture
SELECT count(*) FROM architect WHERE id NOT IN ( SELECT architect_id FROM mill WHERE built_year < 1850 );
How many architects haven't built a mill before year 1850?
school_player
SELECT LOCATION FROM school ORDER BY Enrollment ASC
List the locations of schools in ascending order of enrollment.