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