prompt
stringlengths
81
567
completion
stringlengths
18
557
Question: What are names of countries with the top 3 largest population? Context: CREATE TABLE country (Name VARCHAR, Population VARCHAR) Answer:
SELECT Name FROM country ORDER BY Population DESC LIMIT 3
Question: What are the names of the nations with the 3 lowest populations? Context: CREATE TABLE country (Name VARCHAR, Population VARCHAR) Answer:
SELECT Name FROM country ORDER BY Population LIMIT 3
Question: how many countries are in Asia? Context: CREATE TABLE country (continent VARCHAR) Answer:
SELECT COUNT(*) FROM country WHERE continent = "Asia"
Question: What are the names of the countries that are in the continent of Europe and have a population of 80000? Context: CREATE TABLE country (Name VARCHAR, continent VARCHAR, Population VARCHAR) Answer:
SELECT Name FROM country WHERE continent = "Europe" AND Population = "80000"
Question: What is the total population and average area of countries in the continent of North America whose area is bigger than 3000 ? Context: CREATE TABLE country (population INTEGER, surfacearea INTEGER, continent VARCHAR) Answer:
SELECT SUM(population), AVG(surfacearea) FROM country WHERE continent = "north america" AND surfacearea > 3000
Question: What are the cities whose population is between 160000 and 900000? Context: CREATE TABLE city (name VARCHAR, Population INTEGER) Answer:
SELECT name FROM city WHERE Population BETWEEN 160000 AND 900000
Question: Return the names of cities that have a population between 160000 and 900000 . Context: CREATE TABLE city (name VARCHAR, population INTEGER) Answer:
SELECT name FROM city WHERE population BETWEEN 160000 AND 900000
Question: Which language is spoken by the largest number of countries? Context: CREATE TABLE countrylanguage (LANGUAGE VARCHAR) Answer:
SELECT LANGUAGE FROM countrylanguage GROUP BY LANGUAGE ORDER BY COUNT(*) DESC LIMIT 1
Question: What is the language spoken by the largest percentage of people in each country? Context: CREATE TABLE countrylanguage (LANGUAGE VARCHAR, CountryCode VARCHAR, Percentage INTEGER) Answer:
SELECT LANGUAGE, CountryCode, MAX(Percentage) FROM countrylanguage GROUP BY CountryCode
Question: What is the total number of countries where Spanish is spoken by the largest percentage of people? Context: CREATE TABLE countrylanguage (Percentage INTEGER, CountryCode VARCHAR, LANGUAGE VARCHAR) Answer:
SELECT COUNT(*), MAX(Percentage) FROM countrylanguage WHERE LANGUAGE = "Spanish" GROUP BY CountryCode
Question: What are the codes of countries where Spanish is spoken by the largest percentage of people? Context: CREATE TABLE countrylanguage (CountryCode VARCHAR, Percentage INTEGER, LANGUAGE VARCHAR) Answer:
SELECT CountryCode, MAX(Percentage) FROM countrylanguage WHERE LANGUAGE = "Spanish" GROUP BY CountryCode
Question: How many conductors are there? Context: CREATE TABLE conductor (Id VARCHAR) Answer:
SELECT COUNT(*) FROM conductor
Question: List the names of conductors in ascending order of age. Context: CREATE TABLE conductor (Name VARCHAR, Age VARCHAR) Answer:
SELECT Name FROM conductor ORDER BY Age
Question: What are the names of conductors whose nationalities are not "USA"? Context: CREATE TABLE conductor (Name VARCHAR, Nationality VARCHAR) Answer:
SELECT Name FROM conductor WHERE Nationality <> 'USA'
Question: What are the record companies of orchestras in descending order of years in which they were founded? Context: CREATE TABLE orchestra (Record_Company VARCHAR, Year_of_Founded VARCHAR) Answer:
SELECT Record_Company FROM orchestra ORDER BY Year_of_Founded DESC
Question: What is the average attendance of shows? Context: CREATE TABLE SHOW (Attendance INTEGER) Answer:
SELECT AVG(Attendance) FROM SHOW
Question: What are the maximum and minimum share of performances whose type is not "Live final". Context: CREATE TABLE performance (SHARE INTEGER, TYPE VARCHAR) Answer:
SELECT MAX(SHARE), MIN(SHARE) FROM performance WHERE TYPE <> "Live final"
Question: How many different nationalities do conductors have? Context: CREATE TABLE conductor (Nationality VARCHAR) Answer:
SELECT COUNT(DISTINCT Nationality) FROM conductor
Question: List names of conductors in descending order of years of work. Context: CREATE TABLE conductor (Name VARCHAR, Year_of_Work VARCHAR) Answer:
SELECT Name FROM conductor ORDER BY Year_of_Work DESC
Question: List the name of the conductor with the most years of work. Context: CREATE TABLE conductor (Name VARCHAR, Year_of_Work VARCHAR) Answer:
SELECT Name FROM conductor ORDER BY Year_of_Work DESC LIMIT 1
Question: Show the names of conductors and the orchestras they have conducted. Context: CREATE TABLE conductor (Name VARCHAR, Conductor_ID VARCHAR); CREATE TABLE orchestra (Orchestra VARCHAR, Conductor_ID VARCHAR) Answer:
SELECT T1.Name, T2.Orchestra FROM conductor AS T1 JOIN orchestra AS T2 ON T1.Conductor_ID = T2.Conductor_ID
Question: Show the names of conductors that have conducted more than one orchestras. Context: CREATE TABLE orchestra (Conductor_ID VARCHAR); CREATE TABLE conductor (Name VARCHAR, Conductor_ID VARCHAR) Answer:
SELECT T1.Name FROM conductor AS T1 JOIN orchestra AS T2 ON T1.Conductor_ID = T2.Conductor_ID GROUP BY T2.Conductor_ID HAVING COUNT(*) > 1
Question: Show the name of the conductor that has conducted the most number of orchestras. Context: CREATE TABLE orchestra (Conductor_ID VARCHAR); CREATE TABLE conductor (Name VARCHAR, Conductor_ID VARCHAR) Answer:
SELECT T1.Name FROM conductor AS T1 JOIN orchestra AS T2 ON T1.Conductor_ID = T2.Conductor_ID GROUP BY T2.Conductor_ID ORDER BY COUNT(*) DESC LIMIT 1
Question: Please show the name of the conductor that has conducted orchestras founded after 2008. Context: CREATE TABLE orchestra (Conductor_ID VARCHAR); CREATE TABLE conductor (Name VARCHAR, Conductor_ID VARCHAR) Answer:
SELECT T1.Name FROM conductor AS T1 JOIN orchestra AS T2 ON T1.Conductor_ID = T2.Conductor_ID WHERE Year_of_Founded > 2008
Question: Please show the different record companies and the corresponding number of orchestras. Context: CREATE TABLE orchestra (Record_Company VARCHAR) Answer:
SELECT Record_Company, COUNT(*) FROM orchestra GROUP BY Record_Company
Question: Please show the record formats of orchestras in ascending order of count. Context: CREATE TABLE orchestra (Major_Record_Format VARCHAR) Answer:
SELECT Major_Record_Format FROM orchestra GROUP BY Major_Record_Format ORDER BY COUNT(*)
Question: List the record company shared by the most number of orchestras. Context: CREATE TABLE orchestra (Record_Company VARCHAR) Answer:
SELECT Record_Company FROM orchestra GROUP BY Record_Company ORDER BY COUNT(*) DESC LIMIT 1
Question: List the names of orchestras that have no performance. Context: CREATE TABLE orchestra (Orchestra VARCHAR, Orchestra_ID VARCHAR); CREATE TABLE performance (Orchestra VARCHAR, Orchestra_ID VARCHAR) Answer:
SELECT Orchestra FROM orchestra WHERE NOT Orchestra_ID IN (SELECT Orchestra_ID FROM performance)
Question: Show the record companies shared by orchestras founded before 2003 and after 2003. Context: CREATE TABLE orchestra (Record_Company VARCHAR, Year_of_Founded INTEGER) Answer:
SELECT Record_Company FROM orchestra WHERE Year_of_Founded < 2003 INTERSECT SELECT Record_Company FROM orchestra WHERE Year_of_Founded > 2003
Question: Find the number of orchestras whose record format is "CD" or "DVD". Context: CREATE TABLE orchestra (Major_Record_Format VARCHAR) Answer:
SELECT COUNT(*) FROM orchestra WHERE Major_Record_Format = "CD" OR Major_Record_Format = "DVD"
Question: Show the years in which orchestras that have given more than one performance are founded. Context: CREATE TABLE performance (Orchestra_ID VARCHAR); CREATE TABLE orchestra (Orchestra_ID VARCHAR) Answer:
SELECT Year_of_Founded FROM orchestra AS T1 JOIN performance AS T2 ON T1.Orchestra_ID = T2.Orchestra_ID GROUP BY T2.Orchestra_ID HAVING COUNT(*) > 1
Question: How many high schoolers are there? Context: CREATE TABLE Highschooler (Id VARCHAR) Answer:
SELECT COUNT(*) FROM Highschooler
Question: Show the names and grades of each high schooler. Context: CREATE TABLE Highschooler (name VARCHAR, grade VARCHAR) Answer:
SELECT name, grade FROM Highschooler
Question: Show all the grades of the high schoolers. Context: CREATE TABLE Highschooler (grade VARCHAR) Answer:
SELECT grade FROM Highschooler
Question: What grade is Kyle in? Context: CREATE TABLE Highschooler (grade VARCHAR, name VARCHAR) Answer:
SELECT grade FROM Highschooler WHERE name = "Kyle"
Question: Show the names of all high schoolers in grade 10. Context: CREATE TABLE Highschooler (name VARCHAR, grade VARCHAR) Answer:
SELECT name FROM Highschooler WHERE grade = 10
Question: Show the ID of the high schooler named Kyle. Context: CREATE TABLE Highschooler (ID VARCHAR, name VARCHAR) Answer:
SELECT ID FROM Highschooler WHERE name = "Kyle"
Question: How many high schoolers are there in grade 9 or 10? Context: CREATE TABLE Highschooler (grade VARCHAR) Answer:
SELECT COUNT(*) FROM Highschooler WHERE grade = 9 OR grade = 10
Question: Show the number of high schoolers for each grade. Context: CREATE TABLE Highschooler (grade VARCHAR) Answer:
SELECT grade, COUNT(*) FROM Highschooler GROUP BY grade
Question: Which grade has the most high schoolers? Context: CREATE TABLE Highschooler (grade VARCHAR) Answer:
SELECT grade FROM Highschooler GROUP BY grade ORDER BY COUNT(*) DESC LIMIT 1
Question: Show me all grades that have at least 4 students. Context: CREATE TABLE Highschooler (grade VARCHAR) Answer:
SELECT grade FROM Highschooler GROUP BY grade HAVING COUNT(*) >= 4
Question: Show the student IDs and numbers of friends corresponding to each. Context: CREATE TABLE Friend (student_id VARCHAR) Answer:
SELECT student_id, COUNT(*) FROM Friend GROUP BY student_id
Question: Show the names of high school students and their corresponding number of friends. Context: CREATE TABLE Highschooler (name VARCHAR, id VARCHAR); CREATE TABLE Friend (student_id VARCHAR) Answer:
SELECT T2.name, COUNT(*) FROM Friend AS T1 JOIN Highschooler AS T2 ON T1.student_id = T2.id GROUP BY T1.student_id
Question: What is the name of the high schooler who has the greatest number of friends? Context: CREATE TABLE Highschooler (name VARCHAR, id VARCHAR); CREATE TABLE Friend (student_id VARCHAR) Answer:
SELECT T2.name FROM Friend AS T1 JOIN Highschooler AS T2 ON T1.student_id = T2.id GROUP BY T1.student_id ORDER BY COUNT(*) DESC LIMIT 1
Question: Show the names of high schoolers who have at least 3 friends. Context: CREATE TABLE Highschooler (name VARCHAR, id VARCHAR); CREATE TABLE Friend (student_id VARCHAR) Answer:
SELECT T2.name FROM Friend AS T1 JOIN Highschooler AS T2 ON T1.student_id = T2.id GROUP BY T1.student_id HAVING COUNT(*) >= 3
Question: Show the names of all of the high schooler Kyle's friends. Context: CREATE TABLE Highschooler (name VARCHAR, id VARCHAR); CREATE TABLE Friend (student_id VARCHAR, friend_id VARCHAR); CREATE TABLE Highschooler (id VARCHAR, name VARCHAR) Answer:
SELECT T3.name FROM Friend AS T1 JOIN Highschooler AS T2 ON T1.student_id = T2.id JOIN Highschooler AS T3 ON T1.friend_id = T3.id WHERE T2.name = "Kyle"
Question: How many friends does the high school student Kyle have? Context: CREATE TABLE Friend (student_id VARCHAR); CREATE TABLE Highschooler (id VARCHAR, name VARCHAR) Answer:
SELECT COUNT(*) FROM Friend AS T1 JOIN Highschooler AS T2 ON T1.student_id = T2.id WHERE T2.name = "Kyle"
Question: Show ids of all students who do not have any friends. Context: CREATE TABLE Highschooler (id VARCHAR, student_id VARCHAR); CREATE TABLE Friend (id VARCHAR, student_id VARCHAR) Answer:
SELECT id FROM Highschooler EXCEPT SELECT student_id FROM Friend
Question: Show names of all high school students who do not have any friends. Context: CREATE TABLE Highschooler (name VARCHAR, id VARCHAR); CREATE TABLE Highschooler (name VARCHAR); CREATE TABLE Friend (student_id VARCHAR) Answer:
SELECT name FROM Highschooler EXCEPT SELECT T2.name FROM Friend AS T1 JOIN Highschooler AS T2 ON T1.student_id = T2.id
Question: Show the ids of high schoolers who have friends and are also liked by someone else. Context: CREATE TABLE Likes (student_id VARCHAR, liked_id VARCHAR); CREATE TABLE Friend (student_id VARCHAR, liked_id VARCHAR) Answer:
SELECT student_id FROM Friend INTERSECT SELECT liked_id FROM Likes
Question: Show name of all students who have some friends and also are liked by someone else. Context: CREATE TABLE Highschooler (name VARCHAR, id VARCHAR); CREATE TABLE Likes (student_id VARCHAR, liked_id VARCHAR); CREATE TABLE Friend (student_id VARCHAR, liked_id VARCHAR) Answer:
SELECT T2.name FROM Friend AS T1 JOIN Highschooler AS T2 ON T1.student_id = T2.id INTERSECT SELECT T2.name FROM Likes AS T1 JOIN Highschooler AS T2 ON T1.liked_id = T2.id
Question: Count the number of likes for each student id. Context: CREATE TABLE Likes (student_id VARCHAR) Answer:
SELECT student_id, COUNT(*) FROM Likes GROUP BY student_id
Question: Show the names of high schoolers who have likes, and numbers of likes for each. Context: CREATE TABLE Likes (student_id VARCHAR); CREATE TABLE Highschooler (name VARCHAR, id VARCHAR) Answer:
SELECT T2.name, COUNT(*) FROM Likes AS T1 JOIN Highschooler AS T2 ON T1.student_id = T2.id GROUP BY T1.student_id
Question: What is the name of the high schooler who has the greatest number of likes? Context: CREATE TABLE Likes (student_id VARCHAR); CREATE TABLE Highschooler (name VARCHAR, id VARCHAR) Answer:
SELECT T2.name FROM Likes AS T1 JOIN Highschooler AS T2 ON T1.student_id = T2.id GROUP BY T1.student_id ORDER BY COUNT(*) DESC LIMIT 1
Question: Show the names of students who have at least 2 likes. Context: CREATE TABLE Likes (student_id VARCHAR); CREATE TABLE Highschooler (name VARCHAR, id VARCHAR) Answer:
SELECT T2.name FROM Likes AS T1 JOIN Highschooler AS T2 ON T1.student_id = T2.id GROUP BY T1.student_id HAVING COUNT(*) >= 2
Question: Show the names of students who have a grade higher than 5 and have at least 2 friends. Context: CREATE TABLE Friend (student_id VARCHAR); CREATE TABLE Highschooler (name VARCHAR, id VARCHAR, grade INTEGER) Answer:
SELECT T2.name FROM Friend AS T1 JOIN Highschooler AS T2 ON T1.student_id = T2.id WHERE T2.grade > 5 GROUP BY T1.student_id HAVING COUNT(*) >= 2
Question: How many likes does Kyle have? Context: CREATE TABLE Likes (student_id VARCHAR); CREATE TABLE Highschooler (id VARCHAR, name VARCHAR) Answer:
SELECT COUNT(*) FROM Likes AS T1 JOIN Highschooler AS T2 ON T1.student_id = T2.id WHERE T2.name = "Kyle"
Question: Find the average grade of all students who have some friends. Context: CREATE TABLE Highschooler (id VARCHAR); CREATE TABLE Friend (student_id VARCHAR); CREATE TABLE Highschooler (grade INTEGER, id VARCHAR) Answer:
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)
Question: Find the minimum grade of students who have no friends. Context: CREATE TABLE Highschooler (id VARCHAR); CREATE TABLE Friend (student_id VARCHAR); CREATE TABLE Highschooler (grade INTEGER, id VARCHAR) Answer:
SELECT MIN(grade) FROM Highschooler WHERE NOT id IN (SELECT T1.student_id FROM Friend AS T1 JOIN Highschooler AS T2 ON T1.student_id = T2.id)
Question: Which states have both owners and professionals living there? Context: CREATE TABLE Owners (state VARCHAR); CREATE TABLE Professionals (state VARCHAR) Answer:
SELECT state FROM Owners INTERSECT SELECT state FROM Professionals
Question: What is the average age of the dogs who have gone through any treatments? Context: CREATE TABLE Dogs (age INTEGER, dog_id VARCHAR); CREATE TABLE Treatments (age INTEGER, dog_id VARCHAR) Answer:
SELECT AVG(age) FROM Dogs WHERE dog_id IN (SELECT dog_id FROM Treatments)
Question: Which professionals live in the state of Indiana or have done treatment on more than 2 treatments? List his or her id, last name and cell phone. Context: CREATE TABLE Treatments (professional_id VARCHAR); CREATE TABLE Professionals (professional_id VARCHAR, last_name VARCHAR, cell_number VARCHAR); CREATE TABLE Professionals (professional_id VARCHAR, last_name VARCHAR, cell_number VARCHAR, state VARCHAR) Answer:
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
Question: Which dogs have not cost their owner more than 1000 for treatment ? List the dog names . Context: CREATE TABLE dogs (name VARCHAR, dog_id VARCHAR, cost_of_treatment INTEGER); CREATE TABLE treatments (name VARCHAR, dog_id VARCHAR, cost_of_treatment INTEGER) Answer:
SELECT name FROM dogs WHERE NOT dog_id IN (SELECT dog_id FROM treatments GROUP BY dog_id HAVING SUM(cost_of_treatment) > 1000)
Question: Which first names are used for professionals or owners but are not used as dog names? Context: CREATE TABLE Owners (first_name VARCHAR, name VARCHAR); CREATE TABLE Dogs (first_name VARCHAR, name VARCHAR); CREATE TABLE Professionals (first_name VARCHAR, name VARCHAR) Answer:
SELECT first_name FROM Professionals UNION SELECT first_name FROM Owners EXCEPT SELECT name FROM Dogs
Question: Which professional did not operate any treatment on dogs? List the professional's id, role and email. Context: CREATE TABLE Professionals (professional_id VARCHAR, role_code VARCHAR, email_address VARCHAR); CREATE TABLE Treatments (professional_id VARCHAR) Answer:
SELECT professional_id, role_code, email_address FROM Professionals EXCEPT SELECT T1.professional_id, T1.role_code, T1.email_address FROM Professionals AS T1 JOIN Treatments AS T2 ON T1.professional_id = T2.professional_id
Question: Which owner owns the most dogs? List the owner id, first name and last name. Context: CREATE TABLE Owners (first_name VARCHAR, last_name VARCHAR, owner_id VARCHAR); CREATE TABLE Dogs (owner_id VARCHAR) Answer:
SELECT T1.owner_id, T2.first_name, T2.last_name FROM Dogs AS T1 JOIN Owners AS T2 ON T1.owner_id = T2.owner_id GROUP BY T1.owner_id ORDER BY COUNT(*) DESC LIMIT 1
Question: Which professionals have done at least two treatments? List the professional's id, role, and first name. Context: CREATE TABLE Professionals (professional_id VARCHAR, role_code VARCHAR, first_name VARCHAR); CREATE TABLE Treatments (professional_id VARCHAR) Answer:
SELECT T1.professional_id, T1.role_code, T1.first_name FROM Professionals AS T1 JOIN Treatments AS T2 ON T1.professional_id = T2.professional_id GROUP BY T1.professional_id HAVING COUNT(*) >= 2
Question: What is the name of the breed with the most dogs? Context: CREATE TABLE Dogs (breed_code VARCHAR); CREATE TABLE Breeds (breed_name VARCHAR, breed_code VARCHAR) Answer:
SELECT T1.breed_name FROM Breeds AS T1 JOIN Dogs AS T2 ON T1.breed_code = T2.breed_code GROUP BY T1.breed_name ORDER BY COUNT(*) DESC LIMIT 1
Question: Which owner has paid for the most treatments on his or her dogs? List the owner id and last name. Context: CREATE TABLE Owners (owner_id VARCHAR, last_name VARCHAR); CREATE TABLE Dogs (owner_id VARCHAR, dog_id VARCHAR); CREATE TABLE Treatments (dog_id VARCHAR) Answer:
SELECT T1.owner_id, T1.last_name FROM Owners AS T1 JOIN Dogs AS T2 ON T1.owner_id = T2.owner_id JOIN Treatments AS T3 ON T2.dog_id = T3.dog_id GROUP BY T1.owner_id ORDER BY COUNT(*) DESC LIMIT 1
Question: What is the description of the treatment type that costs the least money in total? Context: CREATE TABLE Treatments (treatment_type_code VARCHAR); CREATE TABLE Treatment_types (treatment_type_description VARCHAR, treatment_type_code VARCHAR) Answer:
SELECT T1.treatment_type_description FROM Treatment_types AS T1 JOIN Treatments AS T2 ON T1.treatment_type_code = T2.treatment_type_code GROUP BY T1.treatment_type_code ORDER BY SUM(cost_of_treatment) LIMIT 1
Question: Which owner has paid the largest amount of money in total for their dogs? Show the owner id and zip code. Context: CREATE TABLE Treatments (dog_id VARCHAR, cost_of_treatment INTEGER); CREATE TABLE Owners (owner_id VARCHAR, zip_code VARCHAR); CREATE TABLE Dogs (owner_id VARCHAR, dog_id VARCHAR) Answer:
SELECT T1.owner_id, T1.zip_code FROM Owners AS T1 JOIN Dogs AS T2 ON T1.owner_id = T2.owner_id JOIN Treatments AS T3 ON T2.dog_id = T3.dog_id GROUP BY T1.owner_id ORDER BY SUM(T3.cost_of_treatment) DESC LIMIT 1
Question: Which professionals have done at least two types of treatments? List the professional id and cell phone. Context: CREATE TABLE Professionals (professional_id VARCHAR, cell_number VARCHAR); CREATE TABLE Treatments (professional_id VARCHAR) Answer:
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
Question: What are the first name and last name of the professionals who have done treatment with cost below average? Context: CREATE TABLE Treatments (cost_of_treatment INTEGER); CREATE TABLE Professionals (first_name VARCHAR, last_name VARCHAR); CREATE TABLE Treatments (Id VARCHAR) Answer:
SELECT DISTINCT T1.first_name, T1.last_name FROM Professionals AS T1 JOIN Treatments AS T2 WHERE cost_of_treatment < (SELECT AVG(cost_of_treatment) FROM Treatments)
Question: List the date of each treatment, together with the first name of the professional who operated it. Context: CREATE TABLE Treatments (date_of_treatment VARCHAR, professional_id VARCHAR); CREATE TABLE Professionals (first_name VARCHAR, professional_id VARCHAR) Answer:
SELECT T1.date_of_treatment, T2.first_name FROM Treatments AS T1 JOIN Professionals AS T2 ON T1.professional_id = T2.professional_id
Question: List the cost of each treatment and the corresponding treatment type description. Context: CREATE TABLE Treatments (cost_of_treatment VARCHAR, treatment_type_code VARCHAR); CREATE TABLE treatment_types (treatment_type_description VARCHAR, treatment_type_code VARCHAR) Answer:
SELECT T1.cost_of_treatment, T2.treatment_type_description FROM Treatments AS T1 JOIN treatment_types AS T2 ON T1.treatment_type_code = T2.treatment_type_code
Question: List each owner's first name, last name, and the size of his for her dog. Context: CREATE TABLE Owners (first_name VARCHAR, last_name VARCHAR, owner_id VARCHAR); CREATE TABLE Dogs (size_code VARCHAR, owner_id VARCHAR) Answer:
SELECT T1.first_name, T1.last_name, T2.size_code FROM Owners AS T1 JOIN Dogs AS T2 ON T1.owner_id = T2.owner_id
Question: List pairs of the owner's first name and the dogs's name. Context: CREATE TABLE Dogs (name VARCHAR, owner_id VARCHAR); CREATE TABLE Owners (first_name VARCHAR, owner_id VARCHAR) Answer:
SELECT T1.first_name, T2.name FROM Owners AS T1 JOIN Dogs AS T2 ON T1.owner_id = T2.owner_id
Question: List the names of the dogs of the rarest breed and the treatment dates of them. Context: CREATE TABLE Dogs (name VARCHAR, dog_id VARCHAR, breed_code VARCHAR); CREATE TABLE Treatments (date_of_treatment VARCHAR, dog_id VARCHAR); CREATE TABLE Dogs (breed_code VARCHAR) Answer:
SELECT T1.name, T2.date_of_treatment FROM Dogs AS T1 JOIN Treatments AS T2 ON T1.dog_id = T2.dog_id WHERE T1.breed_code = (SELECT breed_code FROM Dogs GROUP BY breed_code ORDER BY COUNT(*) LIMIT 1)
Question: Which dogs are owned by someone who lives in Virginia? List the owner's first name and the dog's name. Context: CREATE TABLE Dogs (name VARCHAR, owner_id VARCHAR); CREATE TABLE Owners (first_name VARCHAR, owner_id VARCHAR, state VARCHAR) Answer:
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'
Question: What are the arriving date and the departing date of the dogs who have gone through a treatment? Context: CREATE TABLE Dogs (date_arrived VARCHAR, date_departed VARCHAR, dog_id VARCHAR); CREATE TABLE Treatments (dog_id VARCHAR) Answer:
SELECT DISTINCT T1.date_arrived, T1.date_departed FROM Dogs AS T1 JOIN Treatments AS T2 ON T1.dog_id = T2.dog_id
Question: List the last name of the owner owning the youngest dog. Context: CREATE TABLE Owners (last_name VARCHAR, owner_id VARCHAR); CREATE TABLE Dogs (owner_id VARCHAR, age INTEGER); CREATE TABLE Dogs (age INTEGER) Answer:
SELECT T1.last_name FROM Owners AS T1 JOIN Dogs AS T2 ON T1.owner_id = T2.owner_id WHERE T2.age = (SELECT MAX(age) FROM Dogs)
Question: List the emails of the professionals who live in the state of Hawaii or the state of Wisconsin. Context: CREATE TABLE Professionals (email_address VARCHAR, state VARCHAR) Answer:
SELECT email_address FROM Professionals WHERE state = 'Hawaii' OR state = 'Wisconsin'
Question: What are the arriving date and the departing date of all the dogs? Context: CREATE TABLE Dogs (date_arrived VARCHAR, date_departed VARCHAR) Answer:
SELECT date_arrived, date_departed FROM Dogs
Question: How many dogs went through any treatments? Context: CREATE TABLE Treatments (dog_id VARCHAR) Answer:
SELECT COUNT(DISTINCT dog_id) FROM Treatments
Question: How many professionals have performed any treatment to dogs? Context: CREATE TABLE Treatments (professional_id VARCHAR) Answer:
SELECT COUNT(DISTINCT professional_id) FROM Treatments
Question: Which professionals live in a city containing the substring 'West'? List his or her role, street, city and state. Context: CREATE TABLE professionals (role_code VARCHAR, street VARCHAR, city VARCHAR, state VARCHAR) Answer:
SELECT role_code, street, city, state FROM professionals WHERE city LIKE '%West%'
Question: Which owners live in the state whose name contains the substring 'North'? List his first name, last name and email. Context: CREATE TABLE Owners (first_name VARCHAR, last_name VARCHAR, email_address VARCHAR, state VARCHAR) Answer:
SELECT first_name, last_name, email_address FROM Owners WHERE state LIKE '%North%'
Question: How many dogs have an age below the average? Context: CREATE TABLE Dogs (age INTEGER) Answer:
SELECT COUNT(*) FROM Dogs WHERE age < (SELECT AVG(age) FROM Dogs)
Question: How much does the most recent treatment cost? Context: CREATE TABLE Treatments (cost_of_treatment VARCHAR, date_of_treatment VARCHAR) Answer:
SELECT cost_of_treatment FROM Treatments ORDER BY date_of_treatment DESC LIMIT 1
Question: How many dogs have not gone through any treatment? Context: CREATE TABLE Dogs (dog_id VARCHAR); CREATE TABLE Treatments (dog_id VARCHAR) Answer:
SELECT COUNT(*) FROM Dogs WHERE NOT dog_id IN (SELECT dog_id FROM Treatments)
Question: Tell me the number of dogs that have not received any treatment . Context: CREATE TABLE treatments (dog_id VARCHAR); CREATE TABLE dogs (dog_id VARCHAR) Answer:
SELECT COUNT(*) FROM dogs WHERE NOT dog_id IN (SELECT dog_id FROM treatments)
Question: How many owners temporarily do not have any dogs? Context: CREATE TABLE Dogs (owner_id VARCHAR); CREATE TABLE Owners (owner_id VARCHAR) Answer:
SELECT COUNT(*) FROM Owners WHERE NOT owner_id IN (SELECT owner_id FROM Dogs)
Question: How many professionals did not operate any treatment on dogs? Context: CREATE TABLE Professionals (professional_id VARCHAR); CREATE TABLE Treatments (professional_id VARCHAR) Answer:
SELECT COUNT(*) FROM Professionals WHERE NOT professional_id IN (SELECT professional_id FROM Treatments)
Question: List the dog name, age and weight of the dogs who have been abandoned? 1 stands for yes, and 0 stands for no. Context: CREATE TABLE Dogs (name VARCHAR, age VARCHAR, weight VARCHAR, abandoned_yn VARCHAR) Answer:
SELECT name, age, weight FROM Dogs WHERE abandoned_yn = 1
Question: What is the average age of all the dogs? Context: CREATE TABLE Dogs (age INTEGER) Answer:
SELECT AVG(age) FROM Dogs
Question: What is the age of the oldest dog? Context: CREATE TABLE Dogs (age INTEGER) Answer:
SELECT MAX(age) FROM Dogs
Question: How much does each charge type costs? List both charge type and amount. Context: CREATE TABLE Charges (charge_type VARCHAR, charge_amount VARCHAR) Answer:
SELECT charge_type, charge_amount FROM Charges
Question: How much does the most expensive charge type costs? Context: CREATE TABLE Charges (charge_amount INTEGER) Answer:
SELECT MAX(charge_amount) FROM Charges
Question: List the email, cell phone and home phone of all the professionals. Context: CREATE TABLE professionals (email_address VARCHAR, cell_number VARCHAR, home_phone VARCHAR) Answer:
SELECT email_address, cell_number, home_phone FROM professionals
Question: What are all the possible breed type and size type combinations? Context: CREATE TABLE dogs (breed_code VARCHAR, size_code VARCHAR) Answer:
SELECT DISTINCT breed_code, size_code FROM dogs