db_id
stringclasses 40
values | query
stringlengths 22
608
| question
stringlengths 22
185
|
|---|---|---|
address_1
|
SELECT T1.country FROM City AS T1 JOIN Student AS T2 ON T1.city_code = T2.city_code GROUP BY T1.country ORDER BY count(*) LIMIT 1
|
Give the country with the fewest students.
|
address_1
|
SELECT T1.city_name FROM City AS T1 JOIN Student AS T2 ON T1.city_code = T2.city_code GROUP BY T1.city_code HAVING count(*) >= 3
|
Show names for all cities where at least three students live.
|
address_1
|
SELECT T1.city_name FROM City AS T1 JOIN Student AS T2 ON T1.city_code = T2.city_code GROUP BY T1.city_code HAVING count(*) >= 3
|
What are the names of cities with at least three students?
|
address_1
|
SELECT T1.state FROM City AS T1 JOIN Student AS T2 ON T1.city_code = T2.city_code GROUP BY T1.state HAVING count(*) > 5
|
Show all states where more than 5 students live.
|
address_1
|
SELECT T1.state FROM City AS T1 JOIN Student AS T2 ON T1.city_code = T2.city_code GROUP BY T1.state HAVING count(*) > 5
|
What are the states with more than 5 students?
|
address_1
|
SELECT StuID FROM Student EXCEPT SELECT StuID FROM City AS T1 JOIN Student AS T2 ON T1.city_code = T2.city_code WHERE country = "USA"
|
Show ids for all students who don't live in USA.
|
address_1
|
SELECT StuID FROM Student EXCEPT SELECT StuID FROM City AS T1 JOIN Student AS T2 ON T1.city_code = T2.city_code WHERE country = "USA"
|
What the the student ids for students not living in the USA?
|
address_1
|
SELECT StuID FROM City AS T1 JOIN Student AS T2 ON T1.city_code = T2.city_code WHERE T1.state = "PA" AND T2.sex = 'F'
|
Show ids for all female (sex is F) students living in state PA.
|
address_1
|
SELECT StuID FROM City AS T1 JOIN Student AS T2 ON T1.city_code = T2.city_code WHERE T1.state = "PA" AND T2.sex = 'F'
|
What are the student ids for female students in the state of PA?
|
address_1
|
SELECT StuID FROM City AS T1 JOIN Student AS T2 ON T1.city_code = T2.city_code WHERE T2.sex = 'M' AND T1.country != "USA"
|
Show ids for all male students living outside of USA.
|
address_1
|
SELECT StuID FROM City AS T1 JOIN Student AS T2 ON T1.city_code = T2.city_code WHERE T2.sex = 'M' AND T1.country != "USA"
|
What are the ids for male students not in the USA?
|
address_1
|
SELECT distance FROM Direct_distance WHERE city1_code = "BAL" AND city2_code = "CHI"
|
What is the distance between BAL and CHI?
|
address_1
|
SELECT distance FROM Direct_distance WHERE city1_code = "BAL" AND city2_code = "CHI"
|
Give the distance between BAL and CHI?
|
address_1
|
SELECT distance FROM Direct_distance AS T1 JOIN City AS T2 ON T1.city1_code = T2.city_code JOIN City AS T3 ON T1.city2_code = T3.city_code WHERE T2.city_name = "Boston" AND T3.city_name = "Newark"
|
Show me the distance between Boston and Newark.
|
address_1
|
SELECT distance FROM Direct_distance AS T1 JOIN City AS T2 ON T1.city1_code = T2.city_code JOIN City AS T3 ON T1.city2_code = T3.city_code WHERE T2.city_name = "Boston" AND T3.city_name = "Newark"
|
What is the distance between Boston and Newark?
|
address_1
|
SELECT avg(distance) , min(distance) , max(distance) FROM Direct_distance
|
What is the average, minimum, maximum distance between two cities?
|
address_1
|
SELECT avg(distance) , min(distance) , max(distance) FROM Direct_distance
|
Give the average, minimum, and maximum distances between two cities.
|
address_1
|
SELECT city1_code , city2_code FROM Direct_distance ORDER BY distance DESC LIMIT 1
|
Show me the city code of two cities with maximum distance.
|
address_1
|
SELECT city1_code , city2_code FROM Direct_distance ORDER BY distance DESC LIMIT 1
|
What are the city codes of the cities with the maximum distance?
|
address_1
|
SELECT city1_code , city2_code FROM Direct_distance WHERE distance > (SELECT avg(distance) FROM Direct_distance)
|
Show me the city code of two cities with a distance greater than the average.
|
address_1
|
SELECT city1_code , city2_code FROM Direct_distance WHERE distance > (SELECT avg(distance) FROM Direct_distance)
|
What are the city codes of cities with distance greater than average?
|
address_1
|
SELECT city1_code , city2_code FROM Direct_distance WHERE distance < 1000
|
Show me the city code of two cities with a distance less than 1000.
|
address_1
|
SELECT city1_code , city2_code FROM Direct_distance WHERE distance < 1000
|
What are the city codes corresponding to cities with distances less than 1000?
|
address_1
|
SELECT sum(distance) FROM Direct_distance WHERE city1_code = "BAL"
|
What is the total distance between city BAL and all other cities.
|
address_1
|
SELECT sum(distance) FROM Direct_distance WHERE city1_code = "BAL"
|
What is the sum of distances between BAL and other cities?
|
address_1
|
SELECT avg(distance) FROM Direct_distance AS T1 JOIN City AS T2 ON T1.city1_code = T2.city_code WHERE T2.city_name = "Boston"
|
What is the average distance between Boston and all other cities.
|
address_1
|
SELECT avg(distance) FROM Direct_distance AS T1 JOIN City AS T2 ON T1.city1_code = T2.city_code WHERE T2.city_name = "Boston"
|
Give the average distance between Boston and other cities.
|
address_1
|
SELECT T3.city_name FROM Direct_distance AS T1 JOIN City AS T2 ON T1.city1_code = T2.city_code JOIN City AS T3 ON T1.city2_code = T3.city_code WHERE T2.city_name = "Chicago" ORDER BY distance LIMIT 1
|
What is the name of the city closest to Chicago?
|
address_1
|
SELECT T3.city_name FROM Direct_distance AS T1 JOIN City AS T2 ON T1.city1_code = T2.city_code JOIN City AS T3 ON T1.city2_code = T3.city_code WHERE T2.city_name = "Chicago" ORDER BY distance LIMIT 1
|
Give the name of the nearest city to Chicago.
|
address_1
|
SELECT T3.city_name FROM Direct_distance AS T1 JOIN City AS T2 ON T1.city1_code = T2.city_code JOIN City AS T3 ON T1.city2_code = T3.city_code WHERE T2.city_name = "Boston" ORDER BY distance DESC LIMIT 1
|
What is the name of the city furthest to Boston?
|
address_1
|
SELECT T3.city_name FROM Direct_distance AS T1 JOIN City AS T2 ON T1.city1_code = T2.city_code JOIN City AS T3 ON T1.city2_code = T3.city_code WHERE T2.city_name = "Boston" ORDER BY distance DESC LIMIT 1
|
Give the city name of the city with greatest distance from Boston.
|
address_1
|
SELECT city1_code , sum(distance) FROM Direct_distance GROUP BY city1_code
|
Show all city codes and the total distance to all other cities.
|
address_1
|
SELECT city1_code , sum(distance) FROM Direct_distance GROUP BY city1_code
|
For each city, what is the the city code and sum of distances from each?
|
address_1
|
SELECT T2.city_name , avg(distance) FROM Direct_distance AS T1 JOIN City AS T2 ON T1.city1_code = T2.city_code GROUP BY T1.city1_code
|
Show all city names and the average distance to all other cities.
|
address_1
|
SELECT T2.city_name , avg(distance) FROM Direct_distance AS T1 JOIN City AS T2 ON T1.city1_code = T2.city_code GROUP BY T1.city1_code
|
What are the city name and average distances from each city?
|
address_1
|
SELECT distance FROM Direct_distance AS T1 JOIN Student AS T2 ON T1.city1_code = T2.city_code JOIN Student AS T3 ON T1.city2_code = T3.city_code WHERE T2.Fname = "Linda" AND T2.Lname = "Smith" AND T3.Fname = "Tracy" AND T3.Lname = "Kim"
|
How far do Linda (first name) Smith (last name) and Tracy (first name) Kim (last name) live?
|
address_1
|
SELECT distance FROM Direct_distance AS T1 JOIN Student AS T2 ON T1.city1_code = T2.city_code JOIN Student AS T3 ON T1.city2_code = T3.city_code WHERE T2.Fname = "Linda" AND T2.Lname = "Smith" AND T3.Fname = "Tracy" AND T3.Lname = "Kim"
|
What is the distance between the cities where Linda Smith and Tracy Kim live?
|
address_1
|
SELECT T3.Fname , T3.Lname FROM Direct_distance AS T1 JOIN Student AS T2 ON T1.city1_code = T2.city_code JOIN Student AS T3 ON T1.city2_code = T3.city_code WHERE T2.Fname = "Linda" AND T2.Lname = "Smith" ORDER BY distance DESC LIMIT 1
|
What is the first name and last name of the student living furthest to Linda Smith?
|
address_1
|
SELECT T3.Fname , T3.Lname FROM Direct_distance AS T1 JOIN Student AS T2 ON T1.city1_code = T2.city_code JOIN Student AS T3 ON T1.city2_code = T3.city_code WHERE T2.Fname = "Linda" AND T2.Lname = "Smith" ORDER BY distance DESC LIMIT 1
|
What is the full name of the student who lives furthest from Linda Smith?
|
address_1
|
SELECT state FROM Student AS T1 JOIN City AS T2 ON T1.city_code = T2.city_code WHERE T1.Fname = "Linda"
|
Which state does the student whose first name is Linda live in?
|
address_1
|
SELECT state FROM Student AS T1 JOIN City AS T2 ON T1.city_code = T2.city_code WHERE T1.Fname = "Linda"
|
Give the state that the student with first name Linda lives in.
|
boat_1
|
SELECT * FROM Sailors WHERE age > 30
|
Return all details of sailors who are older than 30.
|
boat_1
|
SELECT * FROM Sailors WHERE age > 30
|
What can you tell me about sailors who are older than age 30?
|
boat_1
|
SELECT name , age FROM Sailors WHERE age < 30
|
Return name and age for sailors who are younger than 30.
|
boat_1
|
SELECT name , age FROM Sailors WHERE age < 30
|
What is the name and age of every sailor who is younger than age 30?
|
boat_1
|
SELECT DISTINCT bid FROM Reserves WHERE sid = 1
|
Find boats reserved by Sailor with id 1.
|
boat_1
|
SELECT DISTINCT bid FROM Reserves WHERE sid = 1
|
What are the different boat ids reserved by the sailor whose id is 1?
|
boat_1
|
SELECT T1.name FROM Sailors AS T1 JOIN Reserves AS T2 ON T1.sid = T2.sid WHERE T2.bid = 102
|
Who reserved boat 102?
|
boat_1
|
SELECT T1.name FROM Sailors AS T1 JOIN Reserves AS T2 ON T1.sid = T2.sid WHERE T2.bid = 102
|
What is the name of the sailor who reserved boat 102?
|
boat_1
|
SELECT DISTINCT bid FROM Reserves
|
Return the unique boat ids (bid) of all reserved boats.
|
boat_1
|
SELECT DISTINCT bid FROM Reserves
|
What are the ids of all boats that are reserved by someone?
|
boat_1
|
SELECT name FROM Sailors WHERE name LIKE '%e%'
|
What is the name of sailors whose names contain letter e?
|
boat_1
|
SELECT name FROM Sailors WHERE name LIKE '%e%'
|
What is the name of every sailor whose name contains the letter e?
|
boat_1
|
SELECT DISTINCT sid FROM Sailors WHERE age > (SELECT min(age) FROM Sailors);
|
return the unique ids of sailors who are older than any sailors.
|
boat_1
|
SELECT DISTINCT sid FROM Sailors WHERE age > (SELECT min(age) FROM Sailors);
|
What is the different id of every sailor who is not the youngest?
|
boat_1
|
SELECT DISTINCT name FROM Sailors WHERE age > (SELECT min(age) FROM Sailors WHERE rating > 7);
|
Return the unique names of sailors who are older than any sailors whose rating is larger than 7.
|
boat_1
|
SELECT DISTINCT name FROM Sailors WHERE age > (SELECT min(age) FROM Sailors WHERE rating > 7);
|
What are the different names of sailors who are older than some other sailor with a rating larger than 7?
|
boat_1
|
SELECT DISTINCT T1.name , T1.sid FROM Sailors AS T1 JOIN Reserves AS T2 ON T1.sid = T2.sid
|
Find the name and id of the sailors who reserved at least one boat?
|
boat_1
|
SELECT DISTINCT T1.name , T1.sid FROM Sailors AS T1 JOIN Reserves AS T2 ON T1.sid = T2.sid
|
What is the name and id of every sailor who reserved one or more boats?
|
boat_1
|
SELECT DISTINCT T1.name , T1.sid FROM Sailors AS T1 JOIN Reserves AS T2 ON T1.sid = T2.sid GROUP BY T2.sid HAVING COUNT(*) > 1
|
Find the id and name of the sailors who reserved more than one boat.
|
boat_1
|
select distinct t1.name , t1.sid from sailors as t1 join reserves as t2 on t1.sid = t2.sid group by t2.sid having count(*) >= 2
|
What are the different names of sailors who reserved two or more boats ?
|
boat_1
|
SELECT DISTINCT T2.sid FROM Boats AS T1 JOIN Reserves AS T2 ON T1.bid = T2.bid WHERE T1.color = 'red' OR T1.color = "blue"
|
Find the id of Sailors (sid) that reserved red or blue boat.
|
boat_1
|
SELECT DISTINCT T2.sid FROM Boats AS T1 JOIN Reserves AS T2 ON T1.bid = T2.bid WHERE T1.color = 'red' OR T1.color = "blue"
|
What are the sids for sailors who reserved red or blue boats?
|
boat_1
|
SELECT DISTINCT T2.sid , T3.name FROM Boats AS T1 JOIN Reserves AS T2 ON T1.bid = T2.bid JOIN Sailors AS T3 ON T2.sid = T3.sid WHERE T1.color = 'red' OR T1.color = "blue"
|
Find the name and id of Sailors (sid) that reserved red or blue boat.
|
boat_1
|
SELECT DISTINCT T2.sid , T3.name FROM Boats AS T1 JOIN Reserves AS T2 ON T1.bid = T2.bid JOIN Sailors AS T3 ON T2.sid = T3.sid WHERE T1.color = 'red' OR T1.color = "blue"
|
What are the names and ids of sailors who reserved red or blue boats?
|
boat_1
|
SELECT DISTINCT T2.sid FROM Boats AS T1 JOIN Reserves AS T2 ON T1.bid = T2.bid WHERE T1.color = 'red' INTERSECT SELECT DISTINCT T2.sid FROM Boats AS T1 JOIN Reserves AS T2 ON T1.bid = T2.bid WHERE T1.color = "blue"
|
Find the id of Sailors (sid) that reserved red and blue boat.
|
boat_1
|
SELECT DISTINCT T2.sid FROM Boats AS T1 JOIN Reserves AS T2 ON T1.bid = T2.bid WHERE T1.color = 'red' INTERSECT SELECT DISTINCT T2.sid FROM Boats AS T1 JOIN Reserves AS T2 ON T1.bid = T2.bid WHERE T1.color = "blue"
|
What are the ids of sailors who reserved red and blue boats?
|
boat_1
|
SELECT DISTINCT T2.sid , T3.name FROM Boats AS T1 JOIN Reserves AS T2 ON T1.bid = T2.bid JOIN Sailors AS T3 ON T2.sid = T3.sid WHERE T1.color = 'red' INTERSECT SELECT DISTINCT T2.sid , T3.name FROM Boats AS T1 JOIN Reserves AS T2 ON T1.bid = T2.bid JOIN Sailors AS T3 ON T2.sid = T3.sid WHERE T1.color = "blue"
|
Find the name and id of Sailors (sid) that reserved red and blue boat.
|
boat_1
|
SELECT DISTINCT T2.sid , T3.name FROM Boats AS T1 JOIN Reserves AS T2 ON T1.bid = T2.bid JOIN Sailors AS T3 ON T2.sid = T3.sid WHERE T1.color = 'red' INTERSECT SELECT DISTINCT T2.sid , T3.name FROM Boats AS T1 JOIN Reserves AS T2 ON T1.bid = T2.bid JOIN Sailors AS T3 ON T2.sid = T3.sid WHERE T1.color = "blue"
|
What are the names and ids of sailors who reserved red and blue boats?
|
boat_1
|
SELECT sid FROM Sailors EXCEPT SELECT sid FROM Reserves
|
What is the ids of sailors that haven’t reserved a boat?
|
boat_1
|
SELECT sid FROM Sailors EXCEPT SELECT sid FROM Reserves
|
What are the ids of sailors who have not reserved a boat?
|
boat_1
|
SELECT sid , name FROM Sailors EXCEPT SELECT T1.sid , T1.name FROM Sailors AS T1 JOIN Reserves AS T2 ON T1.sid = T2.sid
|
what is the name and id of sailors who do not have a reservation of a boat?
|
boat_1
|
SELECT sid , name FROM Sailors EXCEPT SELECT T1.sid , T1.name FROM Sailors AS T1 JOIN Reserves AS T2 ON T1.sid = T2.sid
|
What are the names and ids of all sailors who do not have boat reservations?
|
boat_1
|
SELECT sid FROM Sailors EXCEPT SELECT T1.sid FROM Sailors AS T1 JOIN Reserves AS T2 ON T1.sid = T2.sid
|
Find id for the sailors who do not have a reservation of a boat?
|
boat_1
|
SELECT sid FROM Sailors EXCEPT SELECT T1.sid FROM Sailors AS T1 JOIN Reserves AS T2 ON T1.sid = T2.sid
|
What is id about sailors who do not have boat reservations?
|
boat_1
|
SELECT DISTINCT T1.name FROM Sailors AS T1 JOIN Reserves AS T2 ON T1.sid = T2.sid WHERE T2.bid = 103
|
What is the name of the sailors who reserved boat with id 103?
|
boat_1
|
SELECT DISTINCT T1.name FROM Sailors AS T1 JOIN Reserves AS T2 ON T1.sid = T2.sid WHERE T2.bid = 103
|
Find the name of the sailors who reserved boat with id 103.
|
boat_1
|
SELECT name FROM Sailors WHERE rating > (SELECT min(rating) FROM Sailors WHERE name = 'Luis')
|
What is the name of all sailors whose rating is higher than any sailor named Luis?
|
boat_1
|
SELECT name FROM Sailors WHERE rating > (SELECT min(rating) FROM Sailors WHERE name = 'Luis')
|
What are the sailors' names, the ones whose rating is higher than any sailor named Luis?
|
boat_1
|
SELECT name FROM Sailors WHERE rating > (SELECT max(rating) FROM Sailors WHERE name = 'Luis')
|
What is the name of all sailors whose rating is higher than all sailors named Luis?
|
boat_1
|
SELECT name FROM Sailors WHERE rating > (SELECT max(rating) FROM Sailors WHERE name = 'Luis')
|
What are the names of all sailors with a higher rating than every sailor named Luis?
|
boat_1
|
SELECT DISTINCT T1.name , T1.sid FROM Sailors AS T1 JOIN Reserves AS T2 ON T1.sid = T2.sid WHERE T1.rating > 2
|
what is the name and id of every sailor who has a rating greater than 2 and reserved a boat.
|
boat_1
|
SELECT DISTINCT T1.name , T1.sid FROM Sailors AS T1 JOIN Reserves AS T2 ON T1.sid = T2.sid WHERE T1.rating > 2
|
What are the names and ids of all sailors who have a rating of at least 3 and reserved a boat?
|
boat_1
|
SELECT name , age FROM Sailors WHERE age = ( SELECT max(age) FROM Sailors )
|
Find the name and age of the oldest sailor.
|
boat_1
|
SELECT name , age FROM Sailors WHERE age = ( SELECT max(age) FROM Sailors )
|
What is the name and age of the sailor with maximum age?
|
boat_1
|
SELECT COUNT(*) FROM Sailors
|
how many sailors in total?
|
boat_1
|
SELECT COUNT(*) FROM Sailors
|
How many sailors exist?
|
boat_1
|
SELECT AVG(age) FROM Sailors WHERE rating = 7
|
What is the average age of sailors whose rating is 7?
|
boat_1
|
SELECT AVG(age) FROM Sailors WHERE rating = 7
|
What is average age of all sailors who have a rating of 7?
|
boat_1
|
select count(*) from sailors where name like 'd%'
|
How many sailors whose name starts with letter D exist ?
|
boat_1
|
select count(*) from sailors where name like 'd%'
|
What is the count of the sailors whose name starts with letter D ?
|
boat_1
|
SELECT AVG(rating) , MAX(age) FROM Sailors
|
What are the average rating and max age of all sailors?
|
boat_1
|
SELECT AVG(rating) , MAX(age) FROM Sailors
|
Find the average rating and largest age for the sailors
|
boat_1
|
SELECT bid , count(*) FROM Reserves GROUP BY bid
|
Find the number of reservations for each boat.
|
boat_1
|
SELECT bid , count(*) FROM Reserves GROUP BY bid
|
How many reservations exist for each boat?
|
boat_1
|
SELECT bid , count(*) FROM Reserves GROUP BY bid HAVING bid > 50
|
Find the number of reservations for each boat with id greater than 50.
|
boat_1
|
SELECT bid , count(*) FROM Reserves GROUP BY bid HAVING bid > 50
|
How many reservations exist for each boat with an id greater than 50?
|
boat_1
|
SELECT bid , count(*) FROM Reserves GROUP BY bid HAVING count(*) > 1
|
Find the number of reservations for each boat with more than 1 reservation.
|
boat_1
|
SELECT bid , count(*) FROM Reserves GROUP BY bid HAVING count(*) > 1
|
How many reservations exist for each boat that has more than 1 reservation already?
|
boat_1
|
SELECT bid , count(*) FROM Reserves WHERE sid > 1 GROUP BY bid
|
Find the number of reservations by sailors with id greater than 1 for each boat.
|
Subsets and Splits
World Countries Non-English Languages
The query filters specific database entries based on a particular query pattern, providing limited insight as it simply retrieves rows that match a specific condition.