combined_text
stringlengths 106
1.05k
|
---|
###question:How many lessons were in cancelled state?###answer:SELECT COUNT(*) FROM Lessons WHERE lesson_status_code = "Cancelled"###context:CREATE TABLE Lessons (lesson_status_code VARCHAR) |
###question:List lesson id of all lessons taught by staff with first name as Janessa, last name as Sawayn and nickname containing letter 's'.###answer: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%"###context:CREATE TABLE Lessons (lesson_id VARCHAR, staff_id VARCHAR); CREATE TABLE Staff (staff_id VARCHAR, first_name VARCHAR, last_name VARCHAR) |
###question:How many lessons taught by staff whose first name has letter 'a' in it?###answer:SELECT COUNT(*) FROM Lessons AS T1 JOIN Staff AS T2 ON T1.staff_id = T2.staff_id WHERE T2.first_name LIKE "%a%"###context:CREATE TABLE Lessons (staff_id VARCHAR); CREATE TABLE Staff (staff_id VARCHAR, first_name VARCHAR) |
###question:How long is the total lesson time taught by staff with first name as Janessa and last name as Sawayn?###answer: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"###context:CREATE TABLE Lessons (staff_id VARCHAR); CREATE TABLE Staff (staff_id VARCHAR, first_name VARCHAR, last_name VARCHAR) |
###question:What is average lesson price taught by staff with first name as Janessa and last name as Sawayn?###answer: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"###context:CREATE TABLE Lessons (staff_id VARCHAR); CREATE TABLE Staff (staff_id VARCHAR, first_name VARCHAR, last_name VARCHAR) |
###question:How many lesson does customer with first name Ray took?###answer:SELECT COUNT(*) FROM Lessons AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id WHERE T2.first_name = "Ray"###context:CREATE TABLE Customers (customer_id VARCHAR, first_name VARCHAR); CREATE TABLE Lessons (customer_id VARCHAR) |
###question:Which last names are both used by customers and by staff?###answer:SELECT last_name FROM Customers INTERSECT SELECT last_name FROM Staff###context:CREATE TABLE Customers (last_name VARCHAR); CREATE TABLE Staff (last_name VARCHAR) |
###question:What is the first name of the staff who did not give any lesson?###answer: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###context:CREATE TABLE Lessons (staff_id VARCHAR); CREATE TABLE Staff (first_name VARCHAR); CREATE TABLE Staff (first_name VARCHAR, staff_id VARCHAR) |
###question:What is the id and detail of the vehicle used in lessons for most of the times?###answer: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###context:CREATE TABLE Lessons (vehicle_id VARCHAR); CREATE TABLE Vehicles (vehicle_id VARCHAR, vehicle_details VARCHAR) |
###question:How many faculty do we have?###answer:SELECT COUNT(*) FROM Faculty###context:CREATE TABLE Faculty (Id VARCHAR) |
###question:What ranks do we have for faculty?###answer:SELECT DISTINCT rank FROM Faculty###context:CREATE TABLE Faculty (rank VARCHAR) |
###question:Show all the distinct buildings that have faculty rooms.###answer:SELECT DISTINCT building FROM Faculty###context:CREATE TABLE Faculty (building VARCHAR) |
###question:Show the rank, first name, and last name for all the faculty.###answer:SELECT rank, Fname, Lname FROM 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.###answer:SELECT Fname, Lname, phone FROM Faculty WHERE Sex = 'F'###context:CREATE TABLE Faculty (Fname VARCHAR, Lname VARCHAR, phone VARCHAR, Sex VARCHAR) |
###question:Show ids for all the male faculty.###answer:SELECT FacID FROM Faculty WHERE Sex = 'M'###context:CREATE TABLE Faculty (FacID VARCHAR, Sex VARCHAR) |
###question:How many female Professors do we have?###answer:SELECT COUNT(*) FROM Faculty WHERE Sex = 'F' AND Rank = "Professor"###context:CREATE TABLE Faculty (Sex VARCHAR, Rank VARCHAR) |
###question:Show the phone, room, and building for the faculty named Jerry Prince.###answer:SELECT phone, room, building FROM Faculty WHERE Fname = "Jerry" AND Lname = "Prince"###context:CREATE TABLE Faculty (phone VARCHAR, room VARCHAR, building VARCHAR, Fname VARCHAR, Lname VARCHAR) |
###question:How many Professors are in building NEB?###answer:SELECT COUNT(*) FROM Faculty WHERE Rank = "Professor" AND building = "NEB"###context:CREATE TABLE Faculty (Rank VARCHAR, building VARCHAR) |
###question:Show the first name and last name for all the instructors.###answer:SELECT fname, lname FROM Faculty WHERE Rank = "Instructor"###context:CREATE TABLE Faculty (fname VARCHAR, lname VARCHAR, Rank VARCHAR) |
###question:Show all the buildings along with the number of faculty members the buildings have.###answer:SELECT building, COUNT(*) FROM Faculty GROUP BY building###context:CREATE TABLE Faculty (building VARCHAR) |
###question:Which building has most faculty members?###answer:SELECT building FROM Faculty GROUP BY building ORDER BY COUNT(*) DESC LIMIT 1###context:CREATE TABLE Faculty (building VARCHAR) |
###question:Show all the buildings that have at least 10 professors.###answer:SELECT building FROM Faculty WHERE rank = "Professor" GROUP BY building HAVING COUNT(*) >= 10###context:CREATE TABLE Faculty (building VARCHAR, rank VARCHAR) |
###question:For each faculty rank, show the number of faculty members who have it.###answer:SELECT rank, COUNT(*) FROM Faculty GROUP BY rank###context:CREATE TABLE Faculty (rank VARCHAR) |
###question:Show all the ranks and the number of male and female faculty for each rank.###answer:SELECT rank, sex, COUNT(*) FROM Faculty GROUP BY rank, sex###context:CREATE TABLE Faculty (rank VARCHAR, sex VARCHAR) |
###question:Which rank has the smallest number of faculty members?###answer:SELECT rank FROM Faculty GROUP BY rank ORDER BY COUNT(*) LIMIT 1###context:CREATE TABLE Faculty (rank VARCHAR) |
###question:Show the number of male and female assistant professors.###answer:SELECT sex, COUNT(*) FROM Faculty WHERE rank = "AsstProf" GROUP BY sex###context:CREATE TABLE Faculty (sex VARCHAR, rank VARCHAR) |
###question:What are the first name and last name of Linda Smith's advisor?###answer: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"###context:CREATE TABLE Student (advisor VARCHAR, fname VARCHAR, lname VARCHAR); CREATE TABLE Faculty (fname VARCHAR, lname VARCHAR, FacID VARCHAR) |
###question:Show the ids of students whose advisors are professors.###answer:SELECT T2.StuID FROM Faculty AS T1 JOIN Student AS T2 ON T1.FacID = T2.advisor WHERE T1.rank = "Professor"###context:CREATE TABLE Student (StuID VARCHAR, advisor VARCHAR); CREATE TABLE Faculty (FacID VARCHAR, rank VARCHAR) |
###question:Show first name and last name for all the students advised by Michael Goodrich.###answer: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"###context:CREATE TABLE Faculty (FacID VARCHAR, fname VARCHAR, lname VARCHAR); CREATE TABLE Student (fname VARCHAR, lname VARCHAR, advisor VARCHAR) |
###question:Show the faculty id of each faculty member, along with the number of students he or she advises.###answer:SELECT T1.FacID, COUNT(*) FROM Faculty AS T1 JOIN Student AS T2 ON T1.FacID = T2.advisor GROUP BY T1.FacID###context:CREATE TABLE Faculty (FacID VARCHAR); CREATE TABLE Student (advisor VARCHAR) |
###question:Show all the faculty ranks and the number of students advised by each rank.###answer:SELECT T1.rank, COUNT(*) FROM Faculty AS T1 JOIN Student AS T2 ON T1.FacID = T2.advisor GROUP BY T1.rank###context:CREATE TABLE Student (advisor VARCHAR); CREATE TABLE Faculty (rank VARCHAR, FacID VARCHAR) |
###question:What are the first and last name of the faculty who has the most students?###answer: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###context:CREATE TABLE Student (advisor VARCHAR); CREATE TABLE Faculty (fname VARCHAR, lname VARCHAR, FacID VARCHAR) |
###question:Show the ids for all the faculty members who have at least 2 students.###answer:SELECT T1.FacID FROM Faculty AS T1 JOIN Student AS T2 ON T1.FacID = T2.advisor GROUP BY T1.FacID HAVING COUNT(*) >= 2###context:CREATE TABLE Faculty (FacID VARCHAR); CREATE TABLE Student (advisor VARCHAR) |
###question:Show ids for the faculty members who don't advise any student.###answer:SELECT FacID FROM Faculty EXCEPT SELECT advisor FROM Student###context:CREATE TABLE Faculty (FacID VARCHAR, advisor VARCHAR); CREATE TABLE Student (FacID VARCHAR, advisor VARCHAR) |
###question:What activities do we have?###answer:SELECT activity_name FROM Activity###context:CREATE TABLE Activity (activity_name VARCHAR) |
###question:How many activities do we have?###answer:SELECT COUNT(*) FROM Activity###context:CREATE TABLE Activity (Id VARCHAR) |
###question:How many faculty members participate in an activity?###answer:SELECT COUNT(DISTINCT FacID) FROM Faculty_participates_in###context:CREATE TABLE Faculty_participates_in (FacID VARCHAR) |
###question:Show the ids of the faculty who don't participate in any activity.###answer:SELECT FacID FROM Faculty EXCEPT SELECT FacID FROM Faculty_participates_in###context:CREATE TABLE Faculty (FacID VARCHAR); CREATE TABLE Faculty_participates_in (FacID VARCHAR) |
###question:Show the ids of all the faculty members who participate in an activity and advise a student.###answer:SELECT FacID FROM Faculty_participates_in INTERSECT SELECT advisor FROM Student###context:CREATE TABLE Student (FacID VARCHAR, advisor VARCHAR); CREATE TABLE Faculty_participates_in (FacID VARCHAR, advisor VARCHAR) |
###question:How many activities does Mark Giuliano participate in?###answer: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"###context:CREATE TABLE Faculty_participates_in (facID VARCHAR); CREATE TABLE Faculty (facID VARCHAR, fname VARCHAR, lname VARCHAR) |
###question:Show the names of all the activities Mark Giuliano participates in.###answer: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"###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) |
###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.###answer: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###context:CREATE TABLE Faculty_participates_in (facID VARCHAR); CREATE TABLE Faculty (fname VARCHAR, lname VARCHAR, FacID VARCHAR, facID VARCHAR) |
###question:Show all the activity names and the number of faculty involved in each activity.###answer:SELECT T1.activity_name, COUNT(*) FROM Activity AS T1 JOIN Faculty_participates_in AS T2 ON T1.actID = T2.actID GROUP BY T1.actID###context:CREATE TABLE Faculty_participates_in (actID VARCHAR); CREATE TABLE Activity (activity_name VARCHAR, actID VARCHAR) |
###question:What is the first and last name of the faculty participating in the most activities?###answer: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###context:CREATE TABLE Faculty_participates_in (facID VARCHAR); CREATE TABLE Faculty (fname VARCHAR, lname VARCHAR, FacID VARCHAR, facID VARCHAR) |
###question:What is the name of the activity that has the most faculty members involved in?###answer: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###context:CREATE TABLE Faculty_participates_in (actID VARCHAR); CREATE TABLE Activity (activity_name VARCHAR, actID VARCHAR) |
###question:Show the ids of the students who don't participate in any activity.###answer:SELECT StuID FROM Student EXCEPT SELECT StuID FROM Participates_in###context:CREATE TABLE Participates_in (StuID VARCHAR); CREATE TABLE Student (StuID VARCHAR) |
###question:Show the ids for all the students who participate in an activity and are under 20.###answer:SELECT StuID FROM Participates_in INTERSECT SELECT StuID FROM Student WHERE age < 20###context:CREATE TABLE Student (StuID VARCHAR, age INTEGER); CREATE TABLE Participates_in (StuID VARCHAR, age INTEGER) |
###question:What is the first and last name of the student participating in the most activities?###answer: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###context:CREATE TABLE Student (fname VARCHAR, lname VARCHAR, StuID VARCHAR); CREATE TABLE Participates_in (StuID VARCHAR) |
###question:What is the name of the activity with the most students?###answer: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###context:CREATE TABLE Participates_in (actID VARCHAR); CREATE TABLE Activity (activity_name VARCHAR, actID VARCHAR) |
###question:Find the first names of the faculty members who are playing Canoeing or Kayaking.###answer: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'###context:CREATE TABLE activity (activity_name VARCHAR); CREATE TABLE Faculty_participates_in (facID VARCHAR, actid VARCHAR); CREATE TABLE Faculty (lname VARCHAR, facID VARCHAR) |
###question:Find the first names of professors who are not playing Canoeing or Kayaking.###answer: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'###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) |
###question:Find the first names of the faculty members who participate in Canoeing and Kayaking.###answer: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'###context:CREATE TABLE activity (activity_name VARCHAR); CREATE TABLE Faculty_participates_in (facID VARCHAR, actid VARCHAR); CREATE TABLE Faculty (lname VARCHAR, facID VARCHAR) |
###question:Find the ids of the students who participate in Canoeing and Kayaking.###answer: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'###context:CREATE TABLE activity (actid VARCHAR, activity_name VARCHAR); CREATE TABLE participates_in (stuid VARCHAR) |
###question:Find the name of the airport in the city of Goroka.###answer:SELECT name FROM airports WHERE city = 'Goroka'###context:CREATE TABLE airports (name VARCHAR, city VARCHAR) |
###question:Find the name, city, country, and altitude (or elevation) of the airports in the city of New York.###answer:SELECT name, city, country, elevation FROM airports WHERE city = 'New York'###context:CREATE TABLE airports (name VARCHAR, city VARCHAR, country VARCHAR, elevation VARCHAR) |
###question:How many airlines are there?###answer:SELECT COUNT(*) FROM airlines###context:CREATE TABLE airlines (Id VARCHAR) |
###question:How many airlines does Russia has?###answer:SELECT COUNT(*) FROM airlines WHERE country = 'Russia'###context:CREATE TABLE airlines (country VARCHAR) |
###question:What is the maximum elevation of all airports in the country of Iceland?###answer:SELECT MAX(elevation) FROM airports WHERE country = 'Iceland'###context:CREATE TABLE airports (elevation INTEGER, country VARCHAR) |
###question:Find the name of the airports located in Cuba or Argentina.###answer:SELECT name FROM airports WHERE country = 'Cuba' OR country = 'Argentina'###context:CREATE TABLE airports (name VARCHAR, country VARCHAR) |
###question:Find the country of the airlines whose name starts with 'Orbit'.###answer:SELECT country FROM airlines WHERE name LIKE 'Orbit%'###context:CREATE TABLE airlines (country VARCHAR, name VARCHAR) |
###question:Find the name of airports whose altitude is between -50 and 50.###answer:SELECT name FROM airports WHERE elevation BETWEEN -50 AND 50###context:CREATE TABLE airports (name VARCHAR, elevation INTEGER) |
###question:Which country is the airport that has the highest altitude located in?###answer:SELECT country FROM airports ORDER BY elevation DESC LIMIT 1###context:CREATE TABLE airports (country VARCHAR, elevation VARCHAR) |
###question:Find the number of airports whose name contain the word 'International'.###answer:SELECT COUNT(*) FROM airports WHERE name LIKE '%International%'###context:CREATE TABLE airports (name VARCHAR) |
###question:How many different cities do have some airport in the country of Greenland?###answer:SELECT COUNT(DISTINCT city) FROM airports WHERE country = 'Greenland'###context:CREATE TABLE airports (city VARCHAR, country VARCHAR) |
###question:Find the number of routes operated by American Airlines.###answer:SELECT COUNT(*) FROM airlines AS T1 JOIN routes AS T2 ON T1.alid = T2.alid WHERE T1.name = 'American Airlines'###context:CREATE TABLE routes (alid VARCHAR); CREATE TABLE airlines (alid VARCHAR, name VARCHAR) |
###question:Find the number of routes whose destination airports are in Canada.###answer:SELECT COUNT(*) FROM airports AS T1 JOIN routes AS T2 ON T1.apid = T2.dst_apid WHERE country = 'Canada'###context:CREATE TABLE routes (dst_apid VARCHAR); CREATE TABLE airports (apid VARCHAR) |
###question:Find the name, city, and country of the airport that has the lowest altitude.###answer:SELECT name, city, country FROM airports ORDER BY elevation LIMIT 1###context:CREATE TABLE airports (name VARCHAR, city VARCHAR, country VARCHAR, elevation VARCHAR) |
###question:Find the name, city, and country of the airport that has the highest latitude.###answer:SELECT name, city, country FROM airports ORDER BY elevation DESC LIMIT 1###context:CREATE TABLE airports (name VARCHAR, city VARCHAR, country VARCHAR, elevation VARCHAR) |
###question:Find the name and city of the airport which is the destination of the most number of routes.###answer: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###context:CREATE TABLE airports (name VARCHAR, city VARCHAR, apid VARCHAR); CREATE TABLE routes (dst_apid VARCHAR) |
###question:Find the names of the top 10 airlines that operate the most number of routes.###answer: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###context:CREATE TABLE airlines (name VARCHAR, alid VARCHAR); CREATE TABLE routes (alid VARCHAR) |
###question:Find the name and city of the airport which is the source for the most number of flight routes.###answer: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###context:CREATE TABLE airports (name VARCHAR, city VARCHAR, apid VARCHAR); CREATE TABLE routes (src_apid VARCHAR) |
###question:Find the number of different airports which are the destinations of the American Airlines.###answer:SELECT COUNT(DISTINCT dst_apid) FROM airlines AS T1 JOIN routes AS T2 ON T1.alid = T2.alid WHERE T1.name = 'American Airlines'###context:CREATE TABLE routes (alid VARCHAR); CREATE TABLE airlines (alid VARCHAR, name VARCHAR) |
###question:Which countries has the most number of airlines?###answer:SELECT country FROM airlines GROUP BY country ORDER BY COUNT(*) DESC LIMIT 1###context:CREATE TABLE airlines (country VARCHAR) |
###question:Which countries has the most number of airlines whose active status is 'Y'?###answer:SELECT country FROM airlines WHERE active = 'Y' GROUP BY country ORDER BY COUNT(*) DESC LIMIT 1###context:CREATE TABLE airlines (country VARCHAR, active VARCHAR) |
###question:List all countries and their number of airlines in the descending order of number of airlines.###answer:SELECT country, COUNT(*) FROM airlines GROUP BY country ORDER BY COUNT(*) DESC###context:CREATE TABLE airlines (country VARCHAR) |
###question:How many airports are there per country? Order the countries by decreasing number of airports.###answer:SELECT COUNT(*), country FROM airports GROUP BY country ORDER BY COUNT(*) DESC###context:CREATE TABLE airports (country VARCHAR) |
###question:How many airports are there per city in the United States? Order the cities by decreasing number of airports.###answer:SELECT COUNT(*), city FROM airports WHERE country = 'United States' GROUP BY city ORDER BY COUNT(*) DESC###context:CREATE TABLE airports (city VARCHAR, country VARCHAR) |
###question:Return the cities with more than 3 airports in the United States.###answer:SELECT city FROM airports WHERE country = 'United States' GROUP BY city HAVING COUNT(*) > 3###context:CREATE TABLE airports (city VARCHAR, country VARCHAR) |
###question:How many cities are there that have more than 3 airports?###answer:SELECT COUNT(*) FROM (SELECT city FROM airports GROUP BY city HAVING COUNT(*) > 3)###context:CREATE TABLE airports (city VARCHAR) |
###question:List the cities which have more than one airport and number of airports.###answer:SELECT city, COUNT(*) FROM airports GROUP BY city HAVING COUNT(*) > 1###context:CREATE TABLE airports (city VARCHAR) |
###question:List the cities which have more than 2 airports sorted by the number of airports.###answer:SELECT city FROM airports GROUP BY city HAVING COUNT(*) > 2 ORDER BY COUNT(*)###context:CREATE TABLE airports (city VARCHAR) |
###question:Find the number of routes for each source airport and the airport name.###answer:SELECT COUNT(*), T1.name FROM airports AS T1 JOIN routes AS T2 ON T1.apid = T2.src_apid GROUP BY T1.name###context:CREATE TABLE airports (name VARCHAR, apid VARCHAR); CREATE TABLE routes (src_apid VARCHAR) |
###question:Find the number of routes and airport name for each source airport, order the results by decreasing number of routes.###answer: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###context:CREATE TABLE airports (name VARCHAR, apid VARCHAR); CREATE TABLE routes (src_apid VARCHAR) |
###question:Find the average elevation of all airports for each country.###answer:SELECT AVG(elevation), country FROM airports GROUP BY country###context:CREATE TABLE airports (country VARCHAR, elevation INTEGER) |
###question:Find the cities which have exactly two airports.###answer:SELECT city FROM airports GROUP BY city HAVING COUNT(*) = 2###context:CREATE TABLE airports (city VARCHAR) |
###question:For each country and airline name, how many routes are there?###answer: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###context:CREATE TABLE airlines (country VARCHAR, name VARCHAR, alid VARCHAR); CREATE TABLE routes (alid VARCHAR) |
###question:Find the number of routes with destination airports in Italy.###answer:SELECT COUNT(*) FROM routes AS T1 JOIN airports AS T2 ON T1.dst_apid = T2.apid WHERE T2.country = 'Italy'###context:CREATE TABLE routes (dst_apid VARCHAR); CREATE TABLE airports (apid VARCHAR, country VARCHAR) |
###question:Return the number of routes with destination airport in Italy operated by the airline with name 'American Airlines'.###answer: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'###context:CREATE TABLE routes (dst_apid VARCHAR, alid VARCHAR); CREATE TABLE airports (apid VARCHAR, country VARCHAR); CREATE TABLE airlines (alid VARCHAR, name VARCHAR) |
###question:Find the number of routes that have destination John F Kennedy International Airport.###answer:SELECT COUNT(*) FROM airports AS T1 JOIN routes AS T2 ON T1.apid = T2.dst_apid WHERE T1.name = 'John F Kennedy International Airport'###context:CREATE TABLE airports (apid VARCHAR, name VARCHAR); CREATE TABLE routes (dst_apid VARCHAR) |
###question:Find the number of routes from the United States to Canada.###answer: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')###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) |
###question:Find the id of routes whose source and destination airports are in the United States.###answer: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')###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) |
###question:Find the name of airline which runs the most number of routes.###answer: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###context:CREATE TABLE airlines (name VARCHAR, alid VARCHAR); CREATE TABLE routes (alid VARCHAR) |
###question:Find the busiest source airport that runs most number of routes in China.###answer: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###context:CREATE TABLE routes (src_apid VARCHAR); CREATE TABLE airports (name VARCHAR, apid VARCHAR, country VARCHAR) |
###question:Find the busiest destination airport that runs most number of routes in China.###answer: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###context:CREATE TABLE routes (dst_apid VARCHAR); CREATE TABLE airports (name VARCHAR, apid VARCHAR, country VARCHAR) |
###question:What is the id of the most recent order?###answer:SELECT order_id FROM orders ORDER BY date_order_placed DESC LIMIT 1###context:CREATE TABLE orders (order_id VARCHAR, date_order_placed VARCHAR) |
###question:what are the order id and customer id of the oldest order?###answer:SELECT order_id, customer_id FROM orders ORDER BY date_order_placed LIMIT 1###context:CREATE TABLE orders (order_id VARCHAR, customer_id VARCHAR, date_order_placed VARCHAR) |
###question:Find the id of the order whose shipment tracking number is "3452".###answer:SELECT order_id FROM shipments WHERE shipment_tracking_number = "3452"###context:CREATE TABLE shipments (order_id VARCHAR, shipment_tracking_number VARCHAR) |
###question:Find the ids of all the order items whose product id is 11.###answer:SELECT order_item_id FROM order_items WHERE product_id = 11###context:CREATE TABLE order_items (order_item_id VARCHAR, product_id VARCHAR) |
###question:List the name of all the distinct customers who have orders with status "Packing".###answer:SELECT DISTINCT T1.customer_name FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status = "Packing"###context:CREATE TABLE orders (customer_id VARCHAR, order_status VARCHAR); CREATE TABLE customers (customer_name VARCHAR, customer_id VARCHAR) |
###question:Find the details of all the distinct customers who have orders with status "On Road".###answer:SELECT DISTINCT T1.customer_details FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status = "On Road"###context:CREATE TABLE orders (customer_id VARCHAR, order_status VARCHAR); CREATE TABLE customers (customer_details VARCHAR, customer_id VARCHAR) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.