test.jsonl
comparing changes between versions
Schema
4 columns, 1-100 of 1034 rows
Row details
output
query
schema
tables_used
output
query
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;
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?
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;
Among the cars with more than lowest horsepower, which ones do not have more than 3 cylinders? List the car makeid and make name.
SELECT avg(age) FROM Dogs;
Compute the average age of all the dogs.
SELECT count(*) FROM AIRLINES AS T1 JOIN FLIGHTS AS T2 ON T2.Airline = T1.uid WHERE T1.Airline = "United Airlines" AND T2.DestAirport = "ASY";
Count the number of United Airlines flights arriving in ASY Airport.
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";
Count the number of United Airlines flights that arrive in Aberdeen.
SELECT count(*) FROM conductor;
Count the number of conductors.
SELECT count(*) , max(Percentage) FROM countrylanguage WHERE LANGUAGE = "Spanish" GROUP BY CountryCode;
Count the number of countries for which Spanish is the predominantly spoken language.
SELECT count(*) FROM country WHERE continent = "Asia";
Count the number of countries in Asia.
SELECT count(DISTINCT Nationality) FROM conductor;
Count the number of different nationalities of conductors.
SELECT count(DISTINCT Nationality) FROM people;
Count the number of different nationalities.
SELECT count(DISTINCT template_id) FROM Documents;
Count the number of different templates used for documents.
SELECT count(DISTINCT LOCATION) FROM shop;
Count the number of distinct store locations.
SELECT count(*) FROM Documents AS T1 JOIN Templates AS T2 ON T1.Template_ID = T2.Template_ID WHERE T2.Template_Type_Code = 'PPT';
Count the number of documents that use the PPT template type.
SELECT count(*) FROM Documents;
Count the number of documents.
SELECT count(*) FROM Dogs WHERE age < ( SELECT avg(age) FROM Dogs );
Count the number of dogs of an age below the average.
SELECT count(DISTINCT dog_id) FROM Treatments;
Count the number of dogs that went through a treatment.
SELECT count(*) FROM employee;
Count the number of employees
SELECT count(*) , city FROM employee GROUP BY city;
Count the number of employees for each city.
SELECT count(*) FROM FLIGHTS WHERE SourceAirport = "APG";
Count the number of flights departing from 'APG'.
SELECT count(*) FROM FLIGHTS WHERE DestAirport = "ATO";
Count the number of flights into ATO.
SELECT count(*) FROM Friend AS T1 JOIN Highschooler AS T2 ON T1.student_id = T2.id WHERE T2.name = "Kyle";
Count the number of friends Kyle has.
SELECT count(*) FROM Highschooler WHERE grade = 9 OR grade = 10;
Count the number of high schoolers in grades 9 or 10.
SELECT count(*) FROM Highschooler;
Count the number of high schoolers.
SELECT student_id , count(*) FROM Likes GROUP BY student_id;
Count the number of likes for each student id.
SELECT count(*) FROM matches;
Count the number of matches.
SELECT COUNT(*) FROM orchestra WHERE Major_Record_Format = "CD" OR Major_Record_Format = "DVD";
Count the number of orchestras that have CD or DVD as their record format.
SELECT count(*) FROM Paragraphs AS T1 JOIN Documents AS T2 ON T1.document_ID = T2.document_ID WHERE T2.document_name = 'Summer Show';
Count the number of paragraphs in the document named 'Summer Show'.
SELECT count(*) FROM Paragraphs;
Count the number of paragraphs.
SELECT count(*) FROM poker_player;
Count the number of poker players.
SELECT count(*) FROM Templates WHERE template_type_code = "CV";
Count the number of templates of the type CV.
SELECT count(*) FROM Templates;
Count the number of templates.
SELECT section_description FROM Sections WHERE section_name = 'h';
Describe the section h.
SELECT T1.Airline FROM AIRLINES AS T1 JOIN FLIGHTS AS T2 ON T1.uid = T2.Airline GROUP BY T1.Airline HAVING count(*) > 10;
Find all airlines that have at least 10 flights.
SELECT T1.Airline FROM AIRLINES AS T1 JOIN FLIGHTS AS T2 ON T1.uid = T2.Airline GROUP BY T1.Airline HAVING count(*) < 200;
Find all airlines that have fewer than 200 flights.
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";
Find all airlines that have flights from airport 'CVO' but not from 'APG'.
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";
Find all airlines that have flights from both airports 'APG' and 'CVO'.
SELECT count(*) FROM student AS T1 JOIN has_pet AS T2 ON T1.stuid = T2.stuid WHERE T1.age > 20;
Find number of pets owned by students who are older than 20.
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;
Find the abbreviation and country of the airline that has fewest number of flights?
SELECT DISTINCT T1.date_arrived , T1.date_departed FROM Dogs AS T1 JOIN Treatments AS T2 ON T1.dog_id = T2.dog_id;
Find the arriving date and the departing date of the dogs that received a treatment.
SELECT avg(loser_age) , avg(winner_age) FROM matches;
Find the average age of losers and winners of all matches.
select avg(age) from student where stuid not in (select stuid from has_pet);
Find the average age of students who do not have any pet .
SELECT avg(age) FROM Dogs WHERE dog_id IN ( SELECT dog_id FROM Treatments );
Find the average age of the dogs who went through treatments.
SELECT avg(pet_age) , max(pet_age) , pettype FROM pets GROUP BY pettype;
Find the average and maximum age for each type of pet.
SELECT avg(grade) FROM Highschooler WHERE id IN (SELECT T1.student_id FROM Friend AS T1 JOIN Highschooler AS T2 ON T1.student_id = T2.id);
Find the average grade of all students who have some friends.
SELECT sum(Population) , avg(LifeExpectancy) , Continent FROM country GROUP BY Continent HAVING avg(LifeExpectancy) < 72;
Find the average life expectancy and total population for each continent where the average life expectancy is shorter than 72?
SELECT avg(num_of_staff) FROM museum WHERE open_year < 2009;
Find the average number of staff working for the museums that were open before 2009.
SELECT avg(winner_rank) FROM matches;
Find the average rank of winners in all matches.
SELECT avg(ranking) , T1.first_name FROM players AS T1 JOIN rankings AS T2 ON T1.player_id = T2.player_id GROUP BY T1.first_name;
Find the average ranking for each player and their first name.
SELECT avg(weight) , pettype FROM pets GROUP BY pettype;
Find the average weight for each pet type.
SELECT city FROM employee WHERE age < 30 GROUP BY city HAVING count(*) > 1;
Find the cities that have more than one employee under age 30.
SELECT T1.Name , T1.Population FROM city AS T1 JOIN countrylanguage AS T2 ON T1.CountryCode = T2.CountryCode WHERE T2.Language = "English" ORDER BY T1.Population DESC LIMIT 1;
Find the city with the largest population that uses English.
SELECT country_code FROM players GROUP BY country_code HAVING count(*) > 50;
Find the codes of countries that have more than 50 players.
SELECT DISTINCT breed_code , size_code FROM dogs;
Find the distinct breed type and size type combinations for dogs.
SELECT district FROM shop WHERE Number_products < 3000 INTERSECT SELECT district FROM shop WHERE Number_products > 10000;
Find the districts in which there are both shops selling less than 3000 products and shops selling more than 10000 products.
SELECT T1.fname , T1.age 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.pettype = 'dog' AND T1.stuid NOT IN (SELECT T1.stuid 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.pettype = 'cat');
Find the first name and age of students who have a dog but do not have a cat as a pet.
SELECT DISTINCT T1.fname , T1.age FROM student AS T1 JOIN has_pet AS T2 ON T1.stuid = T2.stuid;
Find the first name and age of students who have a pet.
SELECT first_name , country_code FROM players ORDER BY birth_date LIMIT 1;
Find the first name and country code of the oldest player.
SELECT T1.country_code , T1.first_name FROM players AS T1 JOIN rankings AS T2 ON T1.player_id = T2.player_id ORDER BY T2.tours DESC LIMIT 1;
Find the first name and country code of the player who did the most number of tours.
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;
Find the first name and gender of student who have more than one pet.
select t1.fname 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.pettype = 'cat' intersect select t1.fname 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.pettype = 'dog';
Find the first name of students who have both cat and dog pets .
SELECT DISTINCT T1.Fname 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.pettype = 'cat' OR T3.pettype = 'dog';
Find the first name of students who have cat or dog pet.
select t1.first_name from students as t1 join addresses as t2 on t1.permanent_address_id = t2.address_id where t2.country = 'haiti' or t1.cell_mobile_number = '09700166582';
Find the first name of the students who permanently live in the country Haiti or have the cell phone number 09700166582 .
SELECT T1.first_name , T1.country_code , T1.birth_date FROM players AS T1 JOIN matches AS T2 ON T1.player_id = T2.winner_id ORDER BY T2.winner_rank_points DESC LIMIT 1;
Find the first name, country code and birth date of the winner who has the highest rank points in all matches.
SELECT T1.first_name , T2.name FROM Owners AS T1 JOIN Dogs AS T2 ON T1.owner_id = T2.owner_id WHERE T1.state = 'Virginia';
Find the first names of owners living in Virginia and the names of dogs they own.
SELECT first_name FROM Professionals UNION SELECT first_name FROM Owners EXCEPT SELECT name FROM Dogs;
Find the first names that are used for professionals or owners but are not used as dog names.
SELECT sum(Population) , GovernmentForm FROM country GROUP BY GovernmentForm HAVING avg(LifeExpectancy) > 72;
Find the government form name and total population for each government form whose average life expectancy is longer than 72.
SELECT min(loser_rank) FROM matches;
Find the highest rank of losers in all matches.
SELECT T1.professional_id , T1.cell_number FROM Professionals AS T1 JOIN Treatments AS T2 ON T1.professional_id = T2.professional_id GROUP BY T1.professional_id HAVING count(*) >= 2;
Find the id and cell phone of the professionals who operate two or more types of treatments.
SELECT museum_id , name FROM museum ORDER BY num_of_staff DESC LIMIT 1;
Find the id and name of the museum that has the most staff members?
SELECT petid , weight FROM pets WHERE pet_age > 1;
Find the id and weight of all pets whose age is older than 1.
SELECT stuid FROM student EXCEPT SELECT T1.stuid 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.pettype = 'cat';
Find the id of students who do not have a cat pet.
SELECT T2.petid FROM student AS T1 JOIN has_pet AS T2 ON T1.stuid = T2.stuid WHERE T1.Lname = 'Smith';
Find the id of the pet owned by student whose last name is ‘Smith’.
SELECT professional_id , last_name , cell_number FROM Professionals WHERE state = 'Indiana' UNION SELECT T1.professional_id , T1.last_name , T1.cell_number FROM Professionals AS T1 JOIN Treatments AS T2 ON T1.professional_id = T2.professional_id GROUP BY T1.professional_id HAVING count(*) > 2;
Find the id, last name and cell phone of the professionals who live in the state of Indiana or have performed more than two treatments.
SELECT T1.degree_summary_name FROM Degree_Programs AS T1 JOIN Student_Enrolment AS T2 ON T1.degree_program_id = T2.degree_program_id GROUP BY T1.degree_summary_name ORDER BY count(*) DESC LIMIT 1;
Find the kind of program which most number of students are enrolled in?
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';
Find the last name of the student who has a cat that is age 3.
SELECT T1.last_name FROM Students AS T1 JOIN Addresses AS T2 ON T1.current_address_id = T2.address_id WHERE T2.state_province_county = 'NorthCarolina' EXCEPT SELECT DISTINCT T3.last_name FROM Students AS T3 JOIN Student_Enrolment AS T4 ON T3.student_id = T4.student_id;
Find the last name of the students who currently live in the state of North Carolina but have not registered in any degree program.
SELECT major , age FROM student WHERE stuid NOT IN (SELECT T1.stuid 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.pettype = 'cat');
Find the major and age of students who do not have a cat pet.
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);
Find the make and production time of the cars that were produced in the earliest year?
SELECT manager_name , district FROM shop ORDER BY number_products DESC LIMIT 1;
Find the manager name and district of the shop whose number of products is the largest.
SELECT max(weight) , petType FROM pets GROUP BY petType;
Find the maximum weight for each type of pet. List the maximum weight and pet type.
SELECT min(grade) FROM Highschooler WHERE id NOT IN (SELECT T1.student_id FROM Friend AS T1 JOIN Highschooler AS T2 ON T1.student_id = T2.id);
Find the minimum grade of students who have no friends.
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);
Find the model of the car whose weight is below the average weight.
SELECT t1.name , t1.age FROM visitor AS t1 JOIN visit AS t2 ON t1.id = t2.visitor_id ORDER BY t2.num_of_ticket DESC LIMIT 1;
Find the name and age of the visitor who bought the most tickets at once.
SELECT T2.name , T2.location FROM concert AS T1 JOIN stadium AS T2 ON T1.stadium_id = T2.stadium_id WHERE T1.Year = 2014 INTERSECT SELECT T2.name , T2.location FROM concert AS T1 JOIN stadium AS T2 ON T1.stadium_id = T2.stadium_id WHERE T1.Year = 2015;
Find the name and location of the stadiums which some concerts happened in the years of both 2014 and 2015.
SELECT name , Level_of_membership FROM visitor WHERE Level_of_membership > 4 ORDER BY age DESC;
Find the name and membership level of the visitors whose membership level is higher than 4, and sort by their age from old to young.
SELECT DISTINCT winner_name , winner_rank FROM matches ORDER BY winner_age LIMIT 3;
Find the name and rank of the 3 youngest winners across all matches.
SELECT winner_name , winner_rank_points FROM matches GROUP BY winner_name ORDER BY count(*) DESC LIMIT 1;
Find the name and rank points of the winner who won the most times.
SELECT AirportName FROM Airports WHERE AirportCode NOT IN (SELECT SourceAirport FROM Flights UNION SELECT DestAirport FROM Flights);
Find the name of airports which do not have any flight in and out.
SELECT t1.name FROM employee AS t1 JOIN evaluation AS t2 ON t1.Employee_ID = t2.Employee_ID ORDER BY t2.bonus DESC LIMIT 1;
Find the name of the employee who got the highest one time bonus.
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';
Find the name of the makers that produced some cars in the year of 1970?
SELECT name FROM shop WHERE shop_id NOT IN (SELECT shop_id FROM hiring);
Find the name of the shops that do not hire any employee.
SELECT winner_name FROM matches WHERE tourney_name = 'Australian Open' ORDER BY winner_rank_points DESC LIMIT 1;
Find the name of the winner who has the highest rank points and participated in the Australian Open tourney.
SELECT tourney_name FROM matches GROUP BY tourney_name HAVING count(*) > 10;
Find the name of tourney that has more than 10 matches.
SELECT Name , Population , LifeExpectancy FROM country WHERE Continent = "Asia" ORDER BY SurfaceArea DESC LIMIT 1;
Find the name, population and expected life length of asian country with the largest area?
SELECT name FROM employee WHERE Employee_ID NOT IN (SELECT Employee_ID FROM evaluation);
Find the names of employees who never won any award in the evaluation.
SELECT name FROM shop WHERE number_products > (SELECT avg(number_products) FROM shop);
Find the names of stores whose number products is more than the average number of products.
SELECT name FROM visitor WHERE Level_of_membership > 4 ORDER BY Level_of_membership DESC;
Find the names of the visitors whose membership level is higher than 4, and order the results by the level from high to low.
SELECT count(*) , Directed_by FROM cartoon GROUP BY Directed_by;
Find the number of cartoons directed by each of the listed directors.
SELECT count(*) , District FROM city WHERE Population > (SELECT avg(Population) FROM city) GROUP BY District;
Find the number of cities in each district whose population is greater than the average population of cities?
select count(*) from concert where stadium_id = (select stadium_id from stadium order by capacity desc limit 1);
Find the number of concerts happened in the stadium with the highest capacity .
Select a cell to see row details