training_input
stringlengths 118
1.06k
|
---|
###context:CREATE TABLE pets (pettype VARCHAR, weight INTEGER)
###human: Find the average weight for each pet type.
###assistant: SELECT AVG(weight), pettype FROM pets GROUP BY pettype |
###context:CREATE TABLE student (fname VARCHAR, age VARCHAR, stuid VARCHAR); CREATE TABLE has_pet (stuid VARCHAR)
###human: Find the first name and age of students who have a pet.
###assistant: SELECT DISTINCT T1.fname, T1.age FROM student AS T1 JOIN has_pet AS T2 ON T1.stuid = T2.stuid |
###context:CREATE TABLE has_pet (petid VARCHAR, stuid VARCHAR); CREATE TABLE student (stuid VARCHAR, Lname VARCHAR)
###human: Find the id of the pet owned by student whose last name is ‘Smith’.
###assistant: SELECT T2.petid FROM student AS T1 JOIN has_pet AS T2 ON T1.stuid = T2.stuid WHERE T1.Lname = 'Smith' |
###context:CREATE TABLE has_pet (stuid VARCHAR); CREATE TABLE student (stuid VARCHAR)
###human: Find the number of pets for each student who has any pet and student id.
###assistant: SELECT COUNT(*), T1.stuid FROM student AS T1 JOIN has_pet AS T2 ON T1.stuid = T2.stuid GROUP BY T1.stuid |
###context:CREATE TABLE has_pet (stuid VARCHAR); CREATE TABLE student (stuid VARCHAR)
###human: For students who have pets , how many pets does each student have ? list their ids instead of names .
###assistant: SELECT COUNT(*), t1.stuid FROM student AS t1 JOIN has_pet AS t2 ON t1.stuid = t2.stuid GROUP BY t1.stuid |
###context:CREATE TABLE student (fname VARCHAR, sex VARCHAR, stuid VARCHAR); CREATE TABLE has_pet (stuid VARCHAR)
###human: Find the first name and gender of student who have more than one pet.
###assistant: SELECT T1.fname, T1.sex FROM student AS T1 JOIN has_pet AS T2 ON T1.stuid = T2.stuid GROUP BY T1.stuid HAVING COUNT(*) > 1 |
###context:CREATE TABLE student (lname VARCHAR, stuid VARCHAR); CREATE TABLE has_pet (stuid VARCHAR, petid VARCHAR); CREATE TABLE pets (petid VARCHAR, pet_age VARCHAR, pettype VARCHAR)
###human: Find the last name of the student who has a cat that is age 3.
###assistant: SELECT T1.lname FROM student AS T1 JOIN has_pet AS T2 ON T1.stuid = T2.stuid JOIN pets AS T3 ON T3.petid = T2.petid WHERE T3.pet_age = 3 AND T3.pettype = 'cat' |
###context:CREATE TABLE student (age INTEGER, stuid VARCHAR); CREATE TABLE has_pet (age INTEGER, stuid VARCHAR)
###human: Find the average age of students who do not have any pet .
###assistant: SELECT AVG(age) FROM student WHERE NOT stuid IN (SELECT stuid FROM has_pet) |
###context:CREATE TABLE CONTINENTS (Id VARCHAR)
###human: How many continents are there?
###assistant: SELECT COUNT(*) FROM CONTINENTS |
###context:CREATE TABLE COUNTRIES (Continent VARCHAR); CREATE TABLE CONTINENTS (ContId VARCHAR, Continent VARCHAR)
###human: How many countries does each continent have? List the continent id, continent name and the number of countries.
###assistant: SELECT T1.ContId, T1.Continent, COUNT(*) FROM CONTINENTS AS T1 JOIN COUNTRIES AS T2 ON T1.ContId = T2.Continent GROUP BY T1.ContId |
###context:CREATE TABLE COUNTRIES (Id VARCHAR)
###human: How many countries are listed?
###assistant: SELECT COUNT(*) FROM COUNTRIES |
###context:CREATE TABLE MODEL_LIST (Maker VARCHAR); CREATE TABLE CAR_MAKERS (FullName VARCHAR, Id VARCHAR)
###human: How many models does each car maker produce? List maker full name, id and the number.
###assistant: SELECT T1.FullName, T1.Id, COUNT(*) FROM CAR_MAKERS AS T1 JOIN MODEL_LIST AS T2 ON T1.Id = T2.Maker GROUP BY T1.Id |
###context:CREATE TABLE CARS_DATA (Id VARCHAR, horsepower VARCHAR); CREATE TABLE CAR_NAMES (Model VARCHAR, MakeId VARCHAR)
###human: Which model of the car has the minimum horsepower?
###assistant: SELECT T1.Model FROM CAR_NAMES AS T1 JOIN CARS_DATA AS T2 ON T1.MakeId = T2.Id ORDER BY T2.horsepower LIMIT 1 |
###context:CREATE TABLE CARS_DATA (Id VARCHAR, Weight INTEGER); CREATE TABLE CARS_DATA (Weight INTEGER); CREATE TABLE CAR_NAMES (model VARCHAR, MakeId VARCHAR)
###human: Find the model of the car whose weight is below the average weight.
###assistant: SELECT T1.model FROM CAR_NAMES AS T1 JOIN CARS_DATA AS T2 ON T1.MakeId = T2.Id WHERE T2.Weight < (SELECT AVG(Weight) FROM CARS_DATA) |
###context:CREATE TABLE MODEL_LIST (Maker VARCHAR, model VARCHAR); CREATE TABLE CAR_MAKERS (Maker VARCHAR, Id VARCHAR); CREATE TABLE CARS_DATA (id VARCHAR, year VARCHAR); CREATE TABLE CAR_NAMES (model VARCHAR, MakeId VARCHAR)
###human: Find the name of the makers that produced some cars in the year of 1970?
###assistant: SELECT DISTINCT T1.Maker FROM CAR_MAKERS AS T1 JOIN MODEL_LIST AS T2 ON T1.Id = T2.Maker JOIN CAR_NAMES AS T3 ON T2.model = T3.model JOIN CARS_DATA AS T4 ON T3.MakeId = T4.id WHERE T4.year = '1970' |
###context:CREATE TABLE CARS_DATA (YEAR INTEGER); CREATE TABLE CAR_NAMES (Make VARCHAR, MakeId VARCHAR); CREATE TABLE CARS_DATA (Year VARCHAR, Id VARCHAR)
###human: Find the make and production time of the cars that were produced in the earliest year?
###assistant: SELECT T2.Make, T1.Year FROM CARS_DATA AS T1 JOIN CAR_NAMES AS T2 ON T1.Id = T2.MakeId WHERE T1.Year = (SELECT MIN(YEAR) FROM CARS_DATA) |
###context:CREATE TABLE CARS_DATA (id VARCHAR, year INTEGER); CREATE TABLE MODEL_LIST (model VARCHAR); CREATE TABLE CAR_NAMES (model VARCHAR, MakeId VARCHAR)
###human: Which distinct car models are the produced after 1980?
###assistant: SELECT DISTINCT T1.model FROM MODEL_LIST AS T1 JOIN CAR_NAMES AS T2 ON T1.model = T2.model JOIN CARS_DATA AS T3 ON T2.MakeId = T3.id WHERE T3.year > 1980 |
###context:CREATE TABLE COUNTRIES (continent VARCHAR, CountryId VARCHAR); CREATE TABLE CONTINENTS (Continent VARCHAR, ContId VARCHAR); CREATE TABLE car_makers (Country VARCHAR)
###human: How many car makers are there in each continents? List the continent name and the count.
###assistant: SELECT T1.Continent, COUNT(*) FROM CONTINENTS AS T1 JOIN COUNTRIES AS T2 ON T1.ContId = T2.continent JOIN car_makers AS T3 ON T2.CountryId = T3.Country GROUP BY T1.Continent |
###context:CREATE TABLE CAR_MAKERS (Country VARCHAR); CREATE TABLE COUNTRIES (CountryName VARCHAR, CountryId VARCHAR)
###human: Which of the countries has the most car makers? List the country name.
###assistant: SELECT T2.CountryName FROM CAR_MAKERS AS T1 JOIN COUNTRIES AS T2 ON T1.Country = T2.CountryId GROUP BY T1.Country ORDER BY COUNT(*) DESC LIMIT 1 |
###context:CREATE TABLE model_list (maker VARCHAR); CREATE TABLE car_makers (fullname VARCHAR, id VARCHAR)
###human: How many car models are produced by each maker ? Only list the count and the maker full name .
###assistant: SELECT COUNT(*), t2.fullname FROM model_list AS t1 JOIN car_makers AS t2 ON t1.maker = t2.id GROUP BY t2.id |
###context:CREATE TABLE CAR_MAKERS (FullName VARCHAR, id VARCHAR, Id VARCHAR); CREATE TABLE MODEL_LIST (Maker VARCHAR)
###human: What is the number of car models that are produced by each maker and what is the id and full name of each maker?
###assistant: SELECT COUNT(*), T2.FullName, T2.id FROM MODEL_LIST AS T1 JOIN CAR_MAKERS AS T2 ON T1.Maker = T2.Id GROUP BY T2.id |
###context:CREATE TABLE CARS_DATA (Accelerate VARCHAR, Id VARCHAR); CREATE TABLE CAR_NAMES (MakeId VARCHAR, Make VARCHAR)
###human: What is the accelerate of the car make amc hornet sportabout (sw)?
###assistant: SELECT T1.Accelerate FROM CARS_DATA AS T1 JOIN CAR_NAMES AS T2 ON T1.Id = T2.MakeId WHERE T2.Make = 'amc hornet sportabout (sw)' |
###context:CREATE TABLE COUNTRIES (CountryId VARCHAR, CountryName VARCHAR); CREATE TABLE CAR_MAKERS (Country VARCHAR)
###human: How many car makers are there in france?
###assistant: SELECT COUNT(*) FROM CAR_MAKERS AS T1 JOIN COUNTRIES AS T2 ON T1.Country = T2.CountryId WHERE T2.CountryName = 'france' |
###context:CREATE TABLE CAR_MAKERS (Id VARCHAR, Country VARCHAR); CREATE TABLE COUNTRIES (CountryId VARCHAR, CountryName VARCHAR); CREATE TABLE MODEL_LIST (Maker VARCHAR)
###human: How many car models are produced in the usa?
###assistant: SELECT COUNT(*) FROM MODEL_LIST AS T1 JOIN CAR_MAKERS AS T2 ON T1.Maker = T2.Id JOIN COUNTRIES AS T3 ON T2.Country = T3.CountryId WHERE T3.CountryName = 'usa' |
###context:CREATE TABLE CARS_DATA (mpg INTEGER, Cylinders VARCHAR)
###human: What is the average miles per gallon(mpg) of the cars with 4 cylinders?
###assistant: SELECT AVG(mpg) FROM CARS_DATA WHERE Cylinders = 4 |
###context:CREATE TABLE cars_data (weight INTEGER, cylinders VARCHAR, year VARCHAR)
###human: What is the smallest weight of the car produced with 8 cylinders on 1974 ?
###assistant: SELECT MIN(weight) FROM cars_data WHERE cylinders = 8 AND year = 1974 |
###context:CREATE TABLE MODEL_LIST (Maker VARCHAR, Model VARCHAR)
###human: What are all the makers and models?
###assistant: SELECT Maker, Model FROM MODEL_LIST |
###context:CREATE TABLE CAR_MAKERS (Country VARCHAR); CREATE TABLE COUNTRIES (CountryName VARCHAR, CountryId VARCHAR)
###human: What are the countries having at least one car maker? List name and id.
###assistant: SELECT T1.CountryName, T1.CountryId FROM COUNTRIES AS T1 JOIN CAR_MAKERS AS T2 ON T1.CountryId = T2.Country GROUP BY T1.CountryId HAVING COUNT(*) >= 1 |
###context:CREATE TABLE CARS_DATA (horsepower INTEGER)
###human: What is the number of the cars with horsepower more than 150?
###assistant: SELECT COUNT(*) FROM CARS_DATA WHERE horsepower > 150 |
###context:CREATE TABLE CARS_DATA (YEAR VARCHAR, Weight INTEGER)
###human: What is the average weight of cars each year?
###assistant: SELECT AVG(Weight), YEAR FROM CARS_DATA GROUP BY YEAR |
###context:CREATE TABLE COUNTRIES (CountryName VARCHAR, Continent VARCHAR, CountryId VARCHAR); CREATE TABLE CONTINENTS (ContId VARCHAR, Continent VARCHAR); CREATE TABLE CAR_MAKERS (Country VARCHAR)
###human: Which countries in europe have at least 3 car manufacturers?
###assistant: SELECT T1.CountryName FROM COUNTRIES AS T1 JOIN CONTINENTS AS T2 ON T1.Continent = T2.ContId JOIN CAR_MAKERS AS T3 ON T1.CountryId = T3.Country WHERE T2.Continent = 'europe' GROUP BY T1.CountryName HAVING COUNT(*) >= 3 |
###context:CREATE TABLE CAR_NAMES (Make VARCHAR, MakeId VARCHAR); CREATE TABLE CARS_DATA (horsepower VARCHAR, Id VARCHAR, cylinders VARCHAR)
###human: What is the maximum horsepower and the make of the car models with 3 cylinders?
###assistant: SELECT T2.horsepower, T1.Make FROM CAR_NAMES AS T1 JOIN CARS_DATA AS T2 ON T1.MakeId = T2.Id WHERE T2.cylinders = 3 ORDER BY T2.horsepower DESC LIMIT 1 |
###context:CREATE TABLE CAR_NAMES (Model VARCHAR, MakeId VARCHAR); CREATE TABLE CARS_DATA (Id VARCHAR, mpg VARCHAR)
###human: Which model saves the most gasoline? That is to say, have the maximum miles per gallon.
###assistant: SELECT T1.Model FROM CAR_NAMES AS T1 JOIN CARS_DATA AS T2 ON T1.MakeId = T2.Id ORDER BY T2.mpg DESC LIMIT 1 |
###context:CREATE TABLE cars_data (id VARCHAR, mpg VARCHAR); CREATE TABLE car_names (model VARCHAR, makeid VARCHAR)
###human: What is the car model with the highest mpg ?
###assistant: SELECT t1.model FROM car_names AS t1 JOIN cars_data AS t2 ON t1.makeid = t2.id ORDER BY t2.mpg DESC LIMIT 1 |
###context:CREATE TABLE CARS_DATA (horsepower INTEGER, YEAR INTEGER)
###human: What is the average horsepower of the cars before 1980?
###assistant: SELECT AVG(horsepower) FROM CARS_DATA WHERE YEAR < 1980 |
###context:CREATE TABLE cars_data (horsepower INTEGER, year INTEGER)
###human: What is the average horsepower for all cars produced before 1980 ?
###assistant: SELECT AVG(horsepower) FROM cars_data WHERE year < 1980 |
###context:CREATE TABLE CARS_DATA (edispl INTEGER, Id VARCHAR); CREATE TABLE CAR_NAMES (MakeId VARCHAR, Model VARCHAR)
###human: What is the average edispl of the cars of model volvo?
###assistant: SELECT AVG(T2.edispl) FROM CAR_NAMES AS T1 JOIN CARS_DATA AS T2 ON T1.MakeId = T2.Id WHERE T1.Model = 'volvo' |
###context:CREATE TABLE CARS_DATA (Cylinders VARCHAR, Accelerate INTEGER)
###human: What is the maximum accelerate for different number of cylinders?
###assistant: SELECT MAX(Accelerate), Cylinders FROM CARS_DATA GROUP BY Cylinders |
###context:CREATE TABLE CAR_NAMES (Model VARCHAR)
###human: Which model has the most version(make) of cars?
###assistant: SELECT Model FROM CAR_NAMES GROUP BY Model ORDER BY COUNT(*) DESC LIMIT 1 |
###context:CREATE TABLE CARS_DATA (Cylinders INTEGER)
###human: How many cars have more than 4 cylinders?
###assistant: SELECT COUNT(*) FROM CARS_DATA WHERE Cylinders > 4 |
###context:CREATE TABLE CARS_DATA (YEAR VARCHAR)
###human: how many cars were produced in 1980?
###assistant: SELECT COUNT(*) FROM CARS_DATA WHERE YEAR = 1980 |
###context:CREATE TABLE CAR_MAKERS (Id VARCHAR, FullName VARCHAR); CREATE TABLE MODEL_LIST (Maker VARCHAR)
###human: How many car models were produced by the maker with full name American Motor Company?
###assistant: SELECT COUNT(*) FROM CAR_MAKERS AS T1 JOIN MODEL_LIST AS T2 ON T1.Id = T2.Maker WHERE T1.FullName = 'American Motor Company' |
###context:CREATE TABLE MODEL_LIST (Maker VARCHAR); CREATE TABLE CAR_MAKERS (FullName VARCHAR, Id VARCHAR)
###human: Which makers designed more than 3 car models? List full name and the id.
###assistant: SELECT T1.FullName, T1.Id FROM CAR_MAKERS AS T1 JOIN MODEL_LIST AS T2 ON T1.Id = T2.Maker GROUP BY T1.Id HAVING COUNT(*) > 3 |
###context:CREATE TABLE MODEL_LIST (Model VARCHAR, Maker VARCHAR); CREATE TABLE CAR_MAKERS (Id VARCHAR, FullName VARCHAR); CREATE TABLE CAR_NAMES (Model VARCHAR, MakeId VARCHAR); CREATE TABLE CARS_DATA (Id VARCHAR, weight VARCHAR)
###human: Which distinctive models are produced by maker with the full name General Motors or weighing more than 3500?
###assistant: SELECT DISTINCT T2.Model FROM CAR_NAMES AS T1 JOIN MODEL_LIST AS T2 ON T1.Model = T2.Model JOIN CAR_MAKERS AS T3 ON T2.Maker = T3.Id JOIN CARS_DATA AS T4 ON T1.MakeId = T4.Id WHERE T3.FullName = 'General Motors' OR T4.weight > 3500 |
###context:CREATE TABLE cars_data (year VARCHAR, weight INTEGER)
###human: In which years cars were produced weighing no less than 3000 and no more than 4000 ?
###assistant: SELECT DISTINCT year FROM cars_data WHERE weight BETWEEN 3000 AND 4000 |
###context:CREATE TABLE CARS_DATA (horsepower VARCHAR, accelerate VARCHAR)
###human: What is the horsepower of the car with the largest accelerate?
###assistant: SELECT T1.horsepower FROM CARS_DATA AS T1 ORDER BY T1.accelerate DESC LIMIT 1 |
###context:CREATE TABLE CARS_DATA (cylinders VARCHAR, Id VARCHAR, accelerate VARCHAR); CREATE TABLE CAR_NAMES (MakeId VARCHAR, Model VARCHAR)
###human: For model volvo, how many cylinders does the car with the least accelerate have?
###assistant: SELECT T1.cylinders FROM CARS_DATA AS T1 JOIN CAR_NAMES AS T2 ON T1.Id = T2.MakeId WHERE T2.Model = 'volvo' ORDER BY T1.accelerate LIMIT 1 |
###context:CREATE TABLE CARS_DATA (Accelerate INTEGER, Horsepower VARCHAR)
###human: How many cars have a larger accelerate than the car with the largest horsepower?
###assistant: SELECT COUNT(*) FROM CARS_DATA WHERE Accelerate > (SELECT Accelerate FROM CARS_DATA ORDER BY Horsepower DESC LIMIT 1) |
###context:CREATE TABLE car_makers (country VARCHAR); CREATE TABLE countries (countryid VARCHAR)
###human: How many countries has more than 2 car makers ?
###assistant: SELECT COUNT(*) FROM countries AS t1 JOIN car_makers AS t2 ON t1.countryid = t2.country GROUP BY t1.countryid HAVING COUNT(*) > 2 |
###context:CREATE TABLE CARS_DATA (Cylinders INTEGER)
###human: How many cars has over 6 cylinders?
###assistant: SELECT COUNT(*) FROM CARS_DATA WHERE Cylinders > 6 |
###context:CREATE TABLE CAR_NAMES (Model VARCHAR, MakeId VARCHAR); CREATE TABLE CARS_DATA (Id VARCHAR, Cylinders VARCHAR, horsepower VARCHAR)
###human: For the cars with 4 cylinders, which model has the largest horsepower?
###assistant: SELECT T1.Model FROM CAR_NAMES AS T1 JOIN CARS_DATA AS T2 ON T1.MakeId = T2.Id WHERE T2.Cylinders = 4 ORDER BY T2.horsepower DESC LIMIT 1 |
###context:CREATE TABLE CARS_DATA (Id VARCHAR, Horsepower INTEGER, Cylinders VARCHAR); CREATE TABLE CAR_NAMES (MakeId VARCHAR, Make VARCHAR); CREATE TABLE CARS_DATA (Horsepower INTEGER)
###human: Among the cars with more than lowest horsepower, which ones do not have more than 3 cylinders? List the car makeid and make name.
###assistant: SELECT T2.MakeId, T2.Make FROM CARS_DATA AS T1 JOIN CAR_NAMES AS T2 ON T1.Id = T2.MakeId WHERE T1.Horsepower > (SELECT MIN(Horsepower) FROM CARS_DATA) AND T1.Cylinders <= 3 |
###context:CREATE TABLE cars_data (horsepower INTEGER); CREATE TABLE car_names (makeid VARCHAR, make VARCHAR); CREATE TABLE cars_data (id VARCHAR, horsepower INTEGER, cylinders VARCHAR)
###human: Among the cars that do not have the minimum horsepower , what are the make ids and names of all those with less than 4 cylinders ?
###assistant: SELECT t2.makeid, t2.make FROM cars_data AS t1 JOIN car_names AS t2 ON t1.id = t2.makeid WHERE t1.horsepower > (SELECT MIN(horsepower) FROM cars_data) AND t1.cylinders < 4 |
###context:CREATE TABLE cars_data (mpg INTEGER, cylinders VARCHAR, year VARCHAR)
###human: What is the maximum miles per gallon of the car with 8 cylinders or produced before 1980 ?
###assistant: SELECT MAX(mpg) FROM cars_data WHERE cylinders = 8 OR year < 1980 |
###context:CREATE TABLE CAR_MAKERS (Id VARCHAR, FullName VARCHAR); CREATE TABLE MODEL_LIST (model VARCHAR, Model VARCHAR, Maker VARCHAR); CREATE TABLE CARS_DATA (Id VARCHAR, weight VARCHAR); CREATE TABLE CAR_NAMES (Model VARCHAR, MakeId VARCHAR)
###human: Which models are lighter than 3500 but not built by the 'Ford Motor Company'?
###assistant: SELECT DISTINCT T1.model FROM MODEL_LIST AS T1 JOIN CAR_NAMES AS T2 ON T1.Model = T2.Model JOIN CARS_DATA AS T3 ON T2.MakeId = T3.Id JOIN CAR_MAKERS AS T4 ON T1.Maker = T4.Id WHERE T3.weight < 3500 AND T4.FullName <> 'Ford Motor Company' |
###context:CREATE TABLE countries (CountryName VARCHAR, countryId VARCHAR); CREATE TABLE countries (CountryName VARCHAR); CREATE TABLE CAR_MAKERS (Country VARCHAR)
###human: What are the name of the countries where there is not a single car maker?
###assistant: SELECT CountryName FROM countries EXCEPT SELECT T1.CountryName FROM countries AS T1 JOIN CAR_MAKERS AS T2 ON T1.countryId = T2.Country |
###context:CREATE TABLE car_makers (id VARCHAR, maker VARCHAR); CREATE TABLE model_list (maker VARCHAR, model VARCHAR); CREATE TABLE car_names (model VARCHAR)
###human: Which are the car makers which produce at least 2 models and more than 3 car makers ? List the id and the maker .
###assistant: SELECT t1.id, t1.maker FROM car_makers AS t1 JOIN model_list AS t2 ON t1.id = t2.maker GROUP BY t1.id HAVING COUNT(*) >= 2 INTERSECT SELECT t1.id, t1.maker FROM car_makers AS t1 JOIN model_list AS t2 ON t1.id = t2.maker JOIN car_names AS t3 ON t2.model = t3.model GROUP BY t1.id HAVING COUNT(*) > 3 |
###context:CREATE TABLE CAR_NAMES (model VARCHAR); CREATE TABLE MODEL_LIST (Maker VARCHAR, model VARCHAR); CREATE TABLE CAR_MAKERS (Id VARCHAR, Maker VARCHAR)
###human: What are the ids and makers of all car makers that produce at least 2 models and make more than 3 cars?
###assistant: SELECT T1.Id, T1.Maker FROM CAR_MAKERS AS T1 JOIN MODEL_LIST AS T2 ON T1.Id = T2.Maker GROUP BY T1.Id HAVING COUNT(*) >= 2 INTERSECT SELECT T1.Id, T1.Maker FROM CAR_MAKERS AS T1 JOIN MODEL_LIST AS T2 ON T1.Id = T2.Maker JOIN CAR_NAMES AS T3 ON T2.model = T3.model GROUP BY T1.Id HAVING COUNT(*) > 3 |
###context:CREATE TABLE Countries (countryId VARCHAR, CountryName VARCHAR, CountryId VARCHAR); CREATE TABLE CAR_MAKERS (Country VARCHAR, Id VARCHAR); CREATE TABLE MODEL_LIST (Maker VARCHAR, Model VARCHAR)
###human: What are the id and names of the countries which have more than 3 car makers or produce the 'fiat' model?
###assistant: SELECT T1.countryId, T1.CountryName FROM Countries AS T1 JOIN CAR_MAKERS AS T2 ON T1.CountryId = T2.Country GROUP BY T1.countryId HAVING COUNT(*) > 3 UNION SELECT T1.countryId, T1.CountryName FROM Countries AS T1 JOIN CAR_MAKERS AS T2 ON T1.CountryId = T2.Country JOIN MODEL_LIST AS T3 ON T2.Id = T3.Maker WHERE T3.Model = 'fiat' |
###context:CREATE TABLE model_list (maker VARCHAR, model VARCHAR); CREATE TABLE countries (countryid VARCHAR, countryname VARCHAR); CREATE TABLE car_makers (country VARCHAR, id VARCHAR)
###human: What are the ids and names of all countries that either have more than 3 car makers or produce fiat model ?
###assistant: SELECT t1.countryid, t1.countryname FROM countries AS t1 JOIN car_makers AS t2 ON t1.countryid = t2.country GROUP BY t1.countryid HAVING COUNT(*) > 3 UNION SELECT t1.countryid, t1.countryname FROM countries AS t1 JOIN car_makers AS t2 ON t1.countryid = t2.country JOIN model_list AS t3 ON t2.id = t3.maker WHERE t3.model = 'fiat' |
###context:CREATE TABLE AIRLINES (Country VARCHAR, Airline VARCHAR)
###human: Which country does Airline "JetBlue Airways" belong to?
###assistant: SELECT Country FROM AIRLINES WHERE Airline = "JetBlue Airways" |
###context:CREATE TABLE AIRLINES (Abbreviation VARCHAR, Airline VARCHAR)
###human: What is the abbreviation of Airline "JetBlue Airways"?
###assistant: SELECT Abbreviation FROM AIRLINES WHERE Airline = "JetBlue Airways" |
###context:CREATE TABLE AIRLINES (Airline VARCHAR, Abbreviation VARCHAR, Country VARCHAR)
###human: List all airline names and their abbreviations in "USA".
###assistant: SELECT Airline, Abbreviation FROM AIRLINES WHERE Country = "USA" |
###context:CREATE TABLE AIRPORTS (AirportCode VARCHAR, AirportName VARCHAR, city VARCHAR)
###human: List the airport code and name in the city of Anthony.
###assistant: SELECT AirportCode, AirportName FROM AIRPORTS WHERE city = "Anthony" |
###context:CREATE TABLE AIRLINES (Id VARCHAR)
###human: How many airlines do we have?
###assistant: SELECT COUNT(*) FROM AIRLINES |
###context:CREATE TABLE AIRPORTS (Id VARCHAR)
###human: How many airports do we have?
###assistant: SELECT COUNT(*) FROM AIRPORTS |
###context:CREATE TABLE FLIGHTS (Id VARCHAR)
###human: How many flights do we have?
###assistant: SELECT COUNT(*) FROM FLIGHTS |
###context:CREATE TABLE AIRLINES (Airline VARCHAR, Abbreviation VARCHAR)
###human: Which airline has abbreviation 'UAL'?
###assistant: SELECT Airline FROM AIRLINES WHERE Abbreviation = "UAL" |
###context:CREATE TABLE AIRLINES (Country VARCHAR)
###human: How many airlines are from USA?
###assistant: SELECT COUNT(*) FROM AIRLINES WHERE Country = "USA" |
###context:CREATE TABLE AIRPORTS (City VARCHAR, Country VARCHAR, AirportName VARCHAR)
###human: Which city and country is the Alton airport at?
###assistant: SELECT City, Country FROM AIRPORTS WHERE AirportName = "Alton" |
###context:CREATE TABLE AIRPORTS (AirportName VARCHAR, AirportCode VARCHAR)
###human: What is the airport name for airport 'AKO'?
###assistant: SELECT AirportName FROM AIRPORTS WHERE AirportCode = "AKO" |
###context:CREATE TABLE AIRPORTS (AirportName VARCHAR, City VARCHAR)
###human: What are airport names at City 'Aberdeen'?
###assistant: SELECT AirportName FROM AIRPORTS WHERE City = "Aberdeen" |
###context:CREATE TABLE FLIGHTS (SourceAirport VARCHAR)
###human: How many flights depart from 'APG'?
###assistant: SELECT COUNT(*) FROM FLIGHTS WHERE SourceAirport = "APG" |
###context:CREATE TABLE FLIGHTS (DestAirport VARCHAR)
###human: How many flights have destination ATO?
###assistant: SELECT COUNT(*) FROM FLIGHTS WHERE DestAirport = "ATO" |
###context:CREATE TABLE FLIGHTS (SourceAirport VARCHAR); CREATE TABLE AIRPORTS (AirportCode VARCHAR, City VARCHAR)
###human: How many flights depart from City Aberdeen?
###assistant: SELECT COUNT(*) FROM FLIGHTS AS T1 JOIN AIRPORTS AS T2 ON T1.SourceAirport = T2.AirportCode WHERE T2.City = "Aberdeen" |
###context:CREATE TABLE FLIGHTS (DestAirport VARCHAR); CREATE TABLE AIRPORTS (AirportCode VARCHAR, City VARCHAR)
###human: How many flights arriving in Aberdeen city?
###assistant: SELECT COUNT(*) FROM FLIGHTS AS T1 JOIN AIRPORTS AS T2 ON T1.DestAirport = T2.AirportCode WHERE T2.City = "Aberdeen" |
###context:CREATE TABLE FLIGHTS (DestAirport VARCHAR, SourceAirport VARCHAR); CREATE TABLE AIRPORTS (AirportCode VARCHAR, City VARCHAR)
###human: How many flights depart from City 'Aberdeen' and have destination City 'Ashley'?
###assistant: SELECT COUNT(*) FROM FLIGHTS AS T1 JOIN AIRPORTS AS T2 ON T1.DestAirport = T2.AirportCode JOIN AIRPORTS AS T3 ON T1.SourceAirport = T3.AirportCode WHERE T2.City = "Ashley" AND T3.City = "Aberdeen" |
###context:CREATE TABLE FLIGHTS (Airline VARCHAR); CREATE TABLE AIRLINES (uid VARCHAR, Airline VARCHAR)
###human: How many flights does airline 'JetBlue Airways' have?
###assistant: SELECT COUNT(*) FROM FLIGHTS AS T1 JOIN AIRLINES AS T2 ON T1.Airline = T2.uid WHERE T2.Airline = "JetBlue Airways" |
###context:CREATE TABLE FLIGHTS (Airline VARCHAR, DestAirport VARCHAR); CREATE TABLE AIRLINES (uid VARCHAR, Airline VARCHAR)
###human: How many 'United Airlines' flights go to Airport 'ASY'?
###assistant: SELECT COUNT(*) FROM AIRLINES AS T1 JOIN FLIGHTS AS T2 ON T2.Airline = T1.uid WHERE T1.Airline = "United Airlines" AND T2.DestAirport = "ASY" |
###context:CREATE TABLE FLIGHTS (Airline VARCHAR, SourceAirport VARCHAR); CREATE TABLE AIRLINES (uid VARCHAR, Airline VARCHAR)
###human: How many 'United Airlines' flights depart from Airport 'AHD'?
###assistant: SELECT COUNT(*) FROM AIRLINES AS T1 JOIN FLIGHTS AS T2 ON T2.Airline = T1.uid WHERE T1.Airline = "United Airlines" AND T2.SourceAirport = "AHD" |
###context:CREATE TABLE AIRPORTS (AirportCode VARCHAR, City VARCHAR); CREATE TABLE AIRLINES (uid VARCHAR, Airline VARCHAR); CREATE TABLE FLIGHTS (DestAirport VARCHAR, Airline VARCHAR)
###human: How many United Airlines flights go to City 'Aberdeen'?
###assistant: SELECT COUNT(*) FROM FLIGHTS AS T1 JOIN AIRPORTS AS T2 ON T1.DestAirport = T2.AirportCode JOIN AIRLINES AS T3 ON T3.uid = T1.Airline WHERE T2.City = "Aberdeen" AND T3.Airline = "United Airlines" |
###context:CREATE TABLE FLIGHTS (DestAirport VARCHAR); CREATE TABLE AIRPORTS (City VARCHAR, AirportCode VARCHAR)
###human: Which city has most number of arriving flights?
###assistant: SELECT T1.City FROM AIRPORTS AS T1 JOIN FLIGHTS AS T2 ON T1.AirportCode = T2.DestAirport GROUP BY T1.City ORDER BY COUNT(*) DESC LIMIT 1 |
###context:CREATE TABLE AIRPORTS (City VARCHAR, AirportCode VARCHAR); CREATE TABLE FLIGHTS (SourceAirport VARCHAR)
###human: Which city has most number of departing flights?
###assistant: SELECT T1.City FROM AIRPORTS AS T1 JOIN FLIGHTS AS T2 ON T1.AirportCode = T2.SourceAirport GROUP BY T1.City ORDER BY COUNT(*) DESC LIMIT 1 |
###context:CREATE TABLE FLIGHTS (DestAirport VARCHAR, SourceAirport VARCHAR); CREATE TABLE AIRPORTS (AirportCode VARCHAR)
###human: What is the code of airport that has the highest number of flights?
###assistant: SELECT T1.AirportCode FROM AIRPORTS AS T1 JOIN FLIGHTS AS T2 ON T1.AirportCode = T2.DestAirport OR T1.AirportCode = T2.SourceAirport GROUP BY T1.AirportCode ORDER BY COUNT(*) DESC LIMIT 1 |
###context:CREATE TABLE FLIGHTS (DestAirport VARCHAR, SourceAirport VARCHAR); CREATE TABLE AIRPORTS (AirportCode VARCHAR)
###human: What is the code of airport that has fewest number of flights?
###assistant: SELECT T1.AirportCode FROM AIRPORTS AS T1 JOIN FLIGHTS AS T2 ON T1.AirportCode = T2.DestAirport OR T1.AirportCode = T2.SourceAirport GROUP BY T1.AirportCode ORDER BY COUNT(*) LIMIT 1 |
###context:CREATE TABLE FLIGHTS (Airline VARCHAR); CREATE TABLE AIRLINES (Airline VARCHAR, uid VARCHAR)
###human: Which airline has most number of flights?
###assistant: SELECT T1.Airline FROM AIRLINES AS T1 JOIN FLIGHTS AS T2 ON T1.uid = T2.Airline GROUP BY T1.Airline ORDER BY COUNT(*) DESC LIMIT 1 |
###context:CREATE TABLE FLIGHTS (Airline VARCHAR); CREATE TABLE AIRLINES (Abbreviation VARCHAR, Country VARCHAR, Airline VARCHAR, uid VARCHAR)
###human: Find the abbreviation and country of the airline that has fewest number of flights?
###assistant: SELECT T1.Abbreviation, T1.Country FROM AIRLINES AS T1 JOIN FLIGHTS AS T2 ON T1.uid = T2.Airline GROUP BY T1.Airline ORDER BY COUNT(*) LIMIT 1 |
###context:CREATE TABLE AIRLINES (Airline VARCHAR, uid VARCHAR); CREATE TABLE FLIGHTS (Airline VARCHAR, SourceAirport VARCHAR)
###human: What are airlines that have some flight departing from airport 'AHD'?
###assistant: SELECT T1.Airline FROM AIRLINES AS T1 JOIN FLIGHTS AS T2 ON T1.uid = T2.Airline WHERE T2.SourceAirport = "AHD" |
###context:CREATE TABLE AIRLINES (Airline VARCHAR, uid VARCHAR); CREATE TABLE FLIGHTS (Airline VARCHAR, DestAirport VARCHAR)
###human: What are airlines that have flights arriving at airport 'AHD'?
###assistant: SELECT T1.Airline FROM AIRLINES AS T1 JOIN FLIGHTS AS T2 ON T1.uid = T2.Airline WHERE T2.DestAirport = "AHD" |
###context:CREATE TABLE AIRLINES (Airline VARCHAR, uid VARCHAR); CREATE TABLE FLIGHTS (Airline VARCHAR, SourceAirport VARCHAR)
###human: Find all airlines that have flights from both airports 'APG' and 'CVO'.
###assistant: SELECT T1.Airline FROM AIRLINES AS T1 JOIN FLIGHTS AS T2 ON T1.uid = T2.Airline WHERE T2.SourceAirport = "APG" INTERSECT SELECT T1.Airline FROM AIRLINES AS T1 JOIN FLIGHTS AS T2 ON T1.uid = T2.Airline WHERE T2.SourceAirport = "CVO" |
###context:CREATE TABLE AIRLINES (Airline VARCHAR, uid VARCHAR); CREATE TABLE FLIGHTS (Airline VARCHAR, SourceAirport VARCHAR)
###human: Find all airlines that have flights from airport 'CVO' but not from 'APG'.
###assistant: SELECT T1.Airline FROM AIRLINES AS T1 JOIN FLIGHTS AS T2 ON T1.uid = T2.Airline WHERE T2.SourceAirport = "CVO" EXCEPT SELECT T1.Airline FROM AIRLINES AS T1 JOIN FLIGHTS AS T2 ON T1.uid = T2.Airline WHERE T2.SourceAirport = "APG" |
###context:CREATE TABLE FLIGHTS (Airline VARCHAR); CREATE TABLE AIRLINES (Airline VARCHAR, uid VARCHAR)
###human: Find all airlines that have at least 10 flights.
###assistant: SELECT T1.Airline FROM AIRLINES AS T1 JOIN FLIGHTS AS T2 ON T1.uid = T2.Airline GROUP BY T1.Airline HAVING COUNT(*) > 10 |
###context:CREATE TABLE FLIGHTS (Airline VARCHAR); CREATE TABLE AIRLINES (Airline VARCHAR, uid VARCHAR)
###human: Find all airlines that have fewer than 200 flights.
###assistant: SELECT T1.Airline FROM AIRLINES AS T1 JOIN FLIGHTS AS T2 ON T1.uid = T2.Airline GROUP BY T1.Airline HAVING COUNT(*) < 200 |
###context:CREATE TABLE AIRLINES (uid VARCHAR, Airline VARCHAR); CREATE TABLE FLIGHTS (FlightNo VARCHAR, Airline VARCHAR)
###human: What are flight numbers of Airline "United Airlines"?
###assistant: SELECT T1.FlightNo FROM FLIGHTS AS T1 JOIN AIRLINES AS T2 ON T2.uid = T1.Airline WHERE T2.Airline = "United Airlines" |
###context:CREATE TABLE FLIGHTS (FlightNo VARCHAR, SourceAirport VARCHAR)
###human: What are flight numbers of flights departing from Airport "APG"?
###assistant: SELECT FlightNo FROM FLIGHTS WHERE SourceAirport = "APG" |
###context:CREATE TABLE FLIGHTS (FlightNo VARCHAR, DestAirport VARCHAR)
###human: What are flight numbers of flights arriving at Airport "APG"?
###assistant: SELECT FlightNo FROM FLIGHTS WHERE DestAirport = "APG" |
###context:CREATE TABLE FLIGHTS (FlightNo VARCHAR, SourceAirport VARCHAR); CREATE TABLE AIRPORTS (AirportCode VARCHAR, City VARCHAR)
###human: What are flight numbers of flights departing from City "Aberdeen "?
###assistant: SELECT T1.FlightNo FROM FLIGHTS AS T1 JOIN AIRPORTS AS T2 ON T1.SourceAirport = T2.AirportCode WHERE T2.City = "Aberdeen" |
###context:CREATE TABLE FLIGHTS (FlightNo VARCHAR, DestAirport VARCHAR); CREATE TABLE AIRPORTS (AirportCode VARCHAR, City VARCHAR)
###human: What are flight numbers of flights arriving at City "Aberdeen"?
###assistant: SELECT T1.FlightNo FROM FLIGHTS AS T1 JOIN AIRPORTS AS T2 ON T1.DestAirport = T2.AirportCode WHERE T2.City = "Aberdeen" |
###context:CREATE TABLE Airports (AirportCode VARCHAR, city VARCHAR); CREATE TABLE Flights (DestAirport VARCHAR)
###human: Find the number of flights landing in the city of Aberdeen or Abilene.
###assistant: SELECT COUNT(*) FROM Flights AS T1 JOIN Airports AS T2 ON T1.DestAirport = T2.AirportCode WHERE T2.city = "Aberdeen" OR T2.city = "Abilene" |
###context:CREATE TABLE Flights (AirportName VARCHAR, AirportCode VARCHAR, SourceAirport VARCHAR, DestAirport VARCHAR); CREATE TABLE Airports (AirportName VARCHAR, AirportCode VARCHAR, SourceAirport VARCHAR, DestAirport VARCHAR)
###human: Find the name of airports which do not have any flight in and out.
###assistant: SELECT AirportName FROM Airports WHERE NOT AirportCode IN (SELECT SourceAirport FROM Flights UNION SELECT DestAirport FROM Flights) |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.