instruction
stringlengths
12
244
input
stringlengths
27
489
output
stringlengths
18
557
text
stringlengths
194
1.14k
Find the name of tourney that has more than 10 matches.
CREATE TABLE matches (tourney_name VARCHAR)
SELECT tourney_name FROM matches GROUP BY tourney_name HAVING COUNT(*) > 10
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE matches (tourney_name VARCHAR) Question: Find the name of tourney that has more than 10 matches. [/INST] SELECT tourney_name FROM matches GROUP BY tourney_name HAVING COUNT(*) > 10 </s>
List the names of all winners who played in both 2013 and 2016.
CREATE TABLE matches (winner_name VARCHAR, YEAR VARCHAR)
SELECT winner_name FROM matches WHERE YEAR = 2013 INTERSECT SELECT winner_name FROM matches WHERE YEAR = 2016
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE matches (winner_name VARCHAR, YEAR VARCHAR) Question: List the names of all winners who played in both 2013 and 2016. [/INST] SELECT winner_name FROM matches WHERE YEAR = 2013 INTERSECT SELECT winner_name FROM matches WHERE YEAR = 2016 </s>
List the number of all matches who played in years of 2013 or 2016.
CREATE TABLE matches (YEAR VARCHAR)
SELECT COUNT(*) FROM matches WHERE YEAR = 2013 OR YEAR = 2016
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE matches (YEAR VARCHAR) Question: List the number of all matches who played in years of 2013 or 2016. [/INST] SELECT COUNT(*) FROM matches WHERE YEAR = 2013 OR YEAR = 2016 </s>
What are the country code and first name of the players who won in both tourney WTA Championships and Australian Open?
CREATE TABLE matches (winner_id VARCHAR, tourney_name VARCHAR); CREATE TABLE players (country_code VARCHAR, first_name VARCHAR, player_id VARCHAR)
SELECT T1.country_code, T1.first_name FROM players AS T1 JOIN matches AS T2 ON T1.player_id = T2.winner_id WHERE T2.tourney_name = 'WTA Championships' INTERSECT SELECT T1.country_code, T1.first_name FROM players AS T1 JOIN matches AS T2 ON T1.player_id = T2.winner_id WHERE T2.tourney_name = 'Australian Open'
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE matches (winner_id VARCHAR, tourney_name VARCHAR); CREATE TABLE players (country_code VARCHAR, first_name VARCHAR, player_id VARCHAR) Question: What are the country code and first name of the players who won in both tourney WTA Championships and Australian Open? [/INST] SELECT T1.country_code, T1.first_name FROM players AS T1 JOIN matches AS T2 ON T1.player_id = T2.winner_id WHERE T2.tourney_name = 'WTA Championships' INTERSECT SELECT T1.country_code, T1.first_name FROM players AS T1 JOIN matches AS T2 ON T1.player_id = T2.winner_id WHERE T2.tourney_name = 'Australian Open' </s>
Find the first name and country code of the oldest player.
CREATE TABLE players (first_name VARCHAR, country_code VARCHAR, birth_date VARCHAR)
SELECT TOP 1 first_name, country_code FROM players ORDER BY birth_date
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE players (first_name VARCHAR, country_code VARCHAR, birth_date VARCHAR) Question: Find the first name and country code of the oldest player. [/INST] SELECT TOP 1 first_name, country_code FROM players ORDER BY birth_date </s>
List the first and last name of all players in the order of birth date.
CREATE TABLE players (first_name VARCHAR, last_name VARCHAR, birth_date VARCHAR)
SELECT first_name, last_name FROM players ORDER BY birth_date
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE players (first_name VARCHAR, last_name VARCHAR, birth_date VARCHAR) Question: List the first and last name of all players in the order of birth date. [/INST] SELECT first_name, last_name FROM players ORDER BY birth_date </s>
List the first and last name of all players who are left / L hand in the order of birth date.
CREATE TABLE players (first_name VARCHAR, last_name VARCHAR, hand VARCHAR, birth_date VARCHAR)
SELECT first_name, last_name FROM players WHERE hand = 'L' ORDER BY birth_date
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE players (first_name VARCHAR, last_name VARCHAR, hand VARCHAR, birth_date VARCHAR) Question: List the first and last name of all players who are left / L hand in the order of birth date. [/INST] SELECT first_name, last_name FROM players WHERE hand = 'L' ORDER BY birth_date </s>
Find the first name and country code of the player who did the most number of tours.
CREATE TABLE players (country_code VARCHAR, first_name VARCHAR, player_id VARCHAR); CREATE TABLE rankings (player_id VARCHAR, tours VARCHAR)
SELECT TOP 1 T1.country_code, T1.first_name FROM players AS T1 JOIN rankings AS T2 ON T1.player_id = T2.player_id ORDER BY T2.tours DESC
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE players (country_code VARCHAR, first_name VARCHAR, player_id VARCHAR); CREATE TABLE rankings (player_id VARCHAR, tours VARCHAR) Question: Find the first name and country code of the player who did the most number of tours. [/INST] SELECT TOP 1 T1.country_code, T1.first_name FROM players AS T1 JOIN rankings AS T2 ON T1.player_id = T2.player_id ORDER BY T2.tours DESC </s>
Find the year that has the most number of matches.
CREATE TABLE matches (YEAR VARCHAR)
SELECT TOP 1 YEAR FROM matches GROUP BY YEAR ORDER BY COUNT(*) DESC
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE matches (YEAR VARCHAR) Question: Find the year that has the most number of matches. [/INST] SELECT TOP 1 YEAR FROM matches GROUP BY YEAR ORDER BY COUNT(*) DESC </s>
Find the name and rank points of the winner who won the most times.
CREATE TABLE matches (winner_name VARCHAR, winner_rank_points VARCHAR)
SELECT TOP 1 winner_name, winner_rank_points FROM matches GROUP BY winner_name ORDER BY COUNT(*) DESC
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE matches (winner_name VARCHAR, winner_rank_points VARCHAR) Question: Find the name and rank points of the winner who won the most times. [/INST] SELECT TOP 1 winner_name, winner_rank_points FROM matches GROUP BY winner_name ORDER BY COUNT(*) DESC </s>
Find the name of the winner who has the highest rank points and participated in the Australian Open tourney.
CREATE TABLE matches (winner_name VARCHAR, tourney_name VARCHAR, winner_rank_points VARCHAR)
SELECT TOP 1 winner_name FROM matches WHERE tourney_name = 'Australian Open' ORDER BY winner_rank_points DESC
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE matches (winner_name VARCHAR, tourney_name VARCHAR, winner_rank_points VARCHAR) Question: Find the name of the winner who has the highest rank points and participated in the Australian Open tourney. [/INST] SELECT TOP 1 winner_name FROM matches WHERE tourney_name = 'Australian Open' ORDER BY winner_rank_points DESC </s>
find the names of loser and winner who played in the match with greatest number of minutes.
CREATE TABLE matches (winner_name VARCHAR, loser_name VARCHAR, minutes VARCHAR)
SELECT TOP 1 winner_name, loser_name FROM matches ORDER BY minutes DESC
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE matches (winner_name VARCHAR, loser_name VARCHAR, minutes VARCHAR) Question: find the names of loser and winner who played in the match with greatest number of minutes. [/INST] SELECT TOP 1 winner_name, loser_name FROM matches ORDER BY minutes DESC </s>
Find the average ranking for each player and their first name.
CREATE TABLE players (first_name VARCHAR, player_id VARCHAR); CREATE TABLE rankings (player_id VARCHAR)
SELECT AVG(ranking), T1.first_name FROM players AS T1 JOIN rankings AS T2 ON T1.player_id = T2.player_id GROUP BY T1.first_name
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE players (first_name VARCHAR, player_id VARCHAR); CREATE TABLE rankings (player_id VARCHAR) Question: Find the average ranking for each player and their first name. [/INST] SELECT AVG(ranking), T1.first_name FROM players AS T1 JOIN rankings AS T2 ON T1.player_id = T2.player_id GROUP BY T1.first_name </s>
Find the total ranking points for each player and their first name.
CREATE TABLE players (first_name VARCHAR, player_id VARCHAR); CREATE TABLE rankings (player_id VARCHAR)
SELECT SUM(ranking_points), T1.first_name FROM players AS T1 JOIN rankings AS T2 ON T1.player_id = T2.player_id GROUP BY T1.first_name
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE players (first_name VARCHAR, player_id VARCHAR); CREATE TABLE rankings (player_id VARCHAR) Question: Find the total ranking points for each player and their first name. [/INST] SELECT SUM(ranking_points), T1.first_name FROM players AS T1 JOIN rankings AS T2 ON T1.player_id = T2.player_id GROUP BY T1.first_name </s>
find the number of players for each country.
CREATE TABLE players (country_code VARCHAR)
SELECT COUNT(*), country_code FROM players GROUP BY country_code
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE players (country_code VARCHAR) Question: find the number of players for each country. [/INST] SELECT COUNT(*), country_code FROM players GROUP BY country_code </s>
find the code of the country where has the greatest number of players.
CREATE TABLE players (country_code VARCHAR)
SELECT TOP 1 country_code FROM players GROUP BY country_code ORDER BY COUNT(*) DESC
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE players (country_code VARCHAR) Question: find the code of the country where has the greatest number of players. [/INST] SELECT TOP 1 country_code FROM players GROUP BY country_code ORDER BY COUNT(*) DESC </s>
Find the codes of countries that have more than 50 players.
CREATE TABLE players (country_code VARCHAR)
SELECT country_code FROM players GROUP BY country_code HAVING COUNT(*) > 50
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE players (country_code VARCHAR) Question: Find the codes of countries that have more than 50 players. [/INST] SELECT country_code FROM players GROUP BY country_code HAVING COUNT(*) > 50 </s>
Find the total number of tours for each ranking date.
CREATE TABLE rankings (ranking_date VARCHAR, tours INTEGER)
SELECT SUM(tours), ranking_date FROM rankings GROUP BY ranking_date
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE rankings (ranking_date VARCHAR, tours INTEGER) Question: Find the total number of tours for each ranking date. [/INST] SELECT SUM(tours), ranking_date FROM rankings GROUP BY ranking_date </s>
Find the number of matches happened in each year.
CREATE TABLE matches (YEAR VARCHAR)
SELECT COUNT(*), YEAR FROM matches GROUP BY YEAR
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE matches (YEAR VARCHAR) Question: Find the number of matches happened in each year. [/INST] SELECT COUNT(*), YEAR FROM matches GROUP BY YEAR </s>
Find the name and rank of the 3 youngest winners across all matches.
CREATE TABLE matches (winner_name VARCHAR, winner_rank VARCHAR, winner_age VARCHAR)
SELECT DISTINCT TOP 3 winner_name, winner_rank FROM matches ORDER BY winner_age
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE matches (winner_name VARCHAR, winner_rank VARCHAR, winner_age VARCHAR) Question: Find the name and rank of the 3 youngest winners across all matches. [/INST] SELECT DISTINCT TOP 3 winner_name, winner_rank FROM matches ORDER BY winner_age </s>
How many different winners both participated in the WTA Championships and were left handed?
CREATE TABLE matches (winner_name VARCHAR, tourney_name VARCHAR, winner_hand VARCHAR)
SELECT COUNT(DISTINCT winner_name) FROM matches WHERE tourney_name = 'WTA Championships' AND winner_hand = 'L'
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE matches (winner_name VARCHAR, tourney_name VARCHAR, winner_hand VARCHAR) Question: How many different winners both participated in the WTA Championships and were left handed? [/INST] SELECT COUNT(DISTINCT winner_name) FROM matches WHERE tourney_name = 'WTA Championships' AND winner_hand = 'L' </s>
Find the first name, country code and birth date of the winner who has the highest rank points in all matches.
CREATE TABLE players (first_name VARCHAR, country_code VARCHAR, birth_date VARCHAR, player_id VARCHAR); CREATE TABLE matches (winner_id VARCHAR, winner_rank_points VARCHAR)
SELECT TOP 1 T1.first_name, T1.country_code, T1.birth_date FROM players AS T1 JOIN matches AS T2 ON T1.player_id = T2.winner_id ORDER BY T2.winner_rank_points DESC
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE players (first_name VARCHAR, country_code VARCHAR, birth_date VARCHAR, player_id VARCHAR); CREATE TABLE matches (winner_id VARCHAR, winner_rank_points VARCHAR) Question: Find the first name, country code and birth date of the winner who has the highest rank points in all matches. [/INST] SELECT TOP 1 T1.first_name, T1.country_code, T1.birth_date FROM players AS T1 JOIN matches AS T2 ON T1.player_id = T2.winner_id ORDER BY T2.winner_rank_points DESC </s>
Find the number of players for each hand type.
CREATE TABLE players (hand VARCHAR)
SELECT COUNT(*), hand FROM players GROUP BY hand
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE players (hand VARCHAR) Question: Find the number of players for each hand type. [/INST] SELECT COUNT(*), hand FROM players GROUP BY hand </s>
How many ships ended up being 'Captured'?
CREATE TABLE ship (disposition_of_ship VARCHAR)
SELECT COUNT(*) FROM ship WHERE disposition_of_ship = 'Captured'
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE ship (disposition_of_ship VARCHAR) Question: How many ships ended up being 'Captured'? [/INST] SELECT COUNT(*) FROM ship WHERE disposition_of_ship = 'Captured' </s>
List the name and tonnage ordered by in descending alphaetical order for the names.
CREATE TABLE ship (name VARCHAR, tonnage VARCHAR)
SELECT name, tonnage FROM ship ORDER BY name DESC
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE ship (name VARCHAR, tonnage VARCHAR) Question: List the name and tonnage ordered by in descending alphaetical order for the names. [/INST] SELECT name, tonnage FROM ship ORDER BY name DESC </s>
List the name, date and result of each battle.
CREATE TABLE battle (name VARCHAR, date VARCHAR)
SELECT name, date FROM battle
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE battle (name VARCHAR, date VARCHAR) Question: List the name, date and result of each battle. [/INST] SELECT name, date FROM battle </s>
What is maximum and minimum death toll caused each time?
CREATE TABLE death (killed INTEGER)
SELECT MAX(killed), MIN(killed) FROM death
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE death (killed INTEGER) Question: What is maximum and minimum death toll caused each time? [/INST] SELECT MAX(killed), MIN(killed) FROM death </s>
What is the average number of injuries caused each time?
CREATE TABLE death (injured INTEGER)
SELECT AVG(injured) FROM death
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE death (injured INTEGER) Question: What is the average number of injuries caused each time? [/INST] SELECT AVG(injured) FROM death </s>
What are the death and injury situations caused by the ship with tonnage 't'?
CREATE TABLE ship (Id VARCHAR); CREATE TABLE death (killed VARCHAR, injured VARCHAR, caused_by_ship_id VARCHAR)
SELECT T1.killed, T1.injured FROM death AS T1 JOIN ship AS t2 ON T1.caused_by_ship_id = T2.id WHERE T2.tonnage = 't'
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE ship (Id VARCHAR); CREATE TABLE death (killed VARCHAR, injured VARCHAR, caused_by_ship_id VARCHAR) Question: What are the death and injury situations caused by the ship with tonnage 't'? [/INST] SELECT T1.killed, T1.injured FROM death AS T1 JOIN ship AS t2 ON T1.caused_by_ship_id = T2.id WHERE T2.tonnage = 't' </s>
What are the name and results of the battles when the bulgarian commander is not 'Boril'
CREATE TABLE battle (name VARCHAR, RESULT VARCHAR, bulgarian_commander VARCHAR)
SELECT name, RESULT FROM battle WHERE bulgarian_commander <> 'Boril'
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE battle (name VARCHAR, RESULT VARCHAR, bulgarian_commander VARCHAR) Question: What are the name and results of the battles when the bulgarian commander is not 'Boril' [/INST] SELECT name, RESULT FROM battle WHERE bulgarian_commander <> 'Boril' </s>
What are the different ids and names of the battles that lost any 'Brig' type shipes?
CREATE TABLE ship (lost_in_battle VARCHAR, ship_type VARCHAR); CREATE TABLE battle (id VARCHAR, name VARCHAR)
SELECT DISTINCT T1.id, T1.name FROM battle AS T1 JOIN ship AS T2 ON T1.id = T2.lost_in_battle WHERE T2.ship_type = 'Brig'
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE ship (lost_in_battle VARCHAR, ship_type VARCHAR); CREATE TABLE battle (id VARCHAR, name VARCHAR) Question: What are the different ids and names of the battles that lost any 'Brig' type shipes? [/INST] SELECT DISTINCT T1.id, T1.name FROM battle AS T1 JOIN ship AS T2 ON T1.id = T2.lost_in_battle WHERE T2.ship_type = 'Brig' </s>
What are the ids and names of the battles that led to more than 10 people killed in total.
CREATE TABLE death (caused_by_ship_id VARCHAR, killed INTEGER); CREATE TABLE battle (id VARCHAR, name VARCHAR); CREATE TABLE ship (lost_in_battle VARCHAR, id VARCHAR)
SELECT T1.id, T1.name FROM battle AS T1 JOIN ship AS T2 ON T1.id = T2.lost_in_battle JOIN death AS T3 ON T2.id = T3.caused_by_ship_id GROUP BY T1.id HAVING SUM(T3.killed) > 10
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE death (caused_by_ship_id VARCHAR, killed INTEGER); CREATE TABLE battle (id VARCHAR, name VARCHAR); CREATE TABLE ship (lost_in_battle VARCHAR, id VARCHAR) Question: What are the ids and names of the battles that led to more than 10 people killed in total. [/INST] SELECT T1.id, T1.name FROM battle AS T1 JOIN ship AS T2 ON T1.id = T2.lost_in_battle JOIN death AS T3 ON T2.id = T3.caused_by_ship_id GROUP BY T1.id HAVING SUM(T3.killed) > 10 </s>
What is the ship id and name that caused most total injuries?
CREATE TABLE death (caused_by_ship_id VARCHAR); CREATE TABLE ship (Id VARCHAR)
SELECT TOP 1 T2.id, T2.name FROM death AS T1 JOIN ship AS t2 ON T1.caused_by_ship_id = T2.id GROUP BY T2.id ORDER BY COUNT(*) DESC
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE death (caused_by_ship_id VARCHAR); CREATE TABLE ship (Id VARCHAR) Question: What is the ship id and name that caused most total injuries? [/INST] SELECT TOP 1 T2.id, T2.name FROM death AS T1 JOIN ship AS t2 ON T1.caused_by_ship_id = T2.id GROUP BY T2.id ORDER BY COUNT(*) DESC </s>
What are the distinct battle names which are between bulgarian commander 'Kaloyan' and latin commander 'Baldwin I'?
CREATE TABLE battle (name VARCHAR, bulgarian_commander VARCHAR, latin_commander VARCHAR)
SELECT name FROM battle WHERE bulgarian_commander = 'Kaloyan' AND latin_commander = 'Baldwin I'
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE battle (name VARCHAR, bulgarian_commander VARCHAR, latin_commander VARCHAR) Question: What are the distinct battle names which are between bulgarian commander 'Kaloyan' and latin commander 'Baldwin I'? [/INST] SELECT name FROM battle WHERE bulgarian_commander = 'Kaloyan' AND latin_commander = 'Baldwin I' </s>
How many different results are there for the battles?
CREATE TABLE battle (RESULT VARCHAR)
SELECT COUNT(DISTINCT RESULT) FROM battle
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE battle (RESULT VARCHAR) Question: How many different results are there for the battles? [/INST] SELECT COUNT(DISTINCT RESULT) FROM battle </s>
How many battles did not lose any ship with tonnage '225'?
CREATE TABLE ship (id VARCHAR, lost_in_battle VARCHAR, tonnage VARCHAR); CREATE TABLE battle (id VARCHAR, lost_in_battle VARCHAR, tonnage VARCHAR)
SELECT COUNT(*) FROM battle WHERE NOT id IN (SELECT lost_in_battle FROM ship WHERE tonnage = '225')
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE ship (id VARCHAR, lost_in_battle VARCHAR, tonnage VARCHAR); CREATE TABLE battle (id VARCHAR, lost_in_battle VARCHAR, tonnage VARCHAR) Question: How many battles did not lose any ship with tonnage '225'? [/INST] SELECT COUNT(*) FROM battle WHERE NOT id IN (SELECT lost_in_battle FROM ship WHERE tonnage = '225') </s>
List the name and date the battle that has lost the ship named 'Lettice' and the ship named 'HMS Atalanta'
CREATE TABLE ship (lost_in_battle VARCHAR, name VARCHAR); CREATE TABLE battle (name VARCHAR, date VARCHAR, id VARCHAR)
SELECT T1.name, T1.date FROM battle AS T1 JOIN ship AS T2 ON T1.id = T2.lost_in_battle WHERE T2.name = 'Lettice' INTERSECT SELECT T1.name, T1.date FROM battle AS T1 JOIN ship AS T2 ON T1.id = T2.lost_in_battle WHERE T2.name = 'HMS Atalanta'
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE ship (lost_in_battle VARCHAR, name VARCHAR); CREATE TABLE battle (name VARCHAR, date VARCHAR, id VARCHAR) Question: List the name and date the battle that has lost the ship named 'Lettice' and the ship named 'HMS Atalanta' [/INST] SELECT T1.name, T1.date FROM battle AS T1 JOIN ship AS T2 ON T1.id = T2.lost_in_battle WHERE T2.name = 'Lettice' INTERSECT SELECT T1.name, T1.date FROM battle AS T1 JOIN ship AS T2 ON T1.id = T2.lost_in_battle WHERE T2.name = 'HMS Atalanta' </s>
Show names, results and bulgarian commanders of the battles with no ships lost in the 'English Channel'.
CREATE TABLE ship (lost_in_battle VARCHAR, location VARCHAR); CREATE TABLE battle (name VARCHAR, RESULT VARCHAR, bulgarian_commander VARCHAR); CREATE TABLE battle (name VARCHAR, result VARCHAR, bulgarian_commander VARCHAR, id VARCHAR)
SELECT name, RESULT, bulgarian_commander FROM battle EXCEPT SELECT T1.name, T1.result, T1.bulgarian_commander FROM battle AS T1 JOIN ship AS T2 ON T1.id = T2.lost_in_battle WHERE T2.location = 'English Channel'
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE ship (lost_in_battle VARCHAR, location VARCHAR); CREATE TABLE battle (name VARCHAR, RESULT VARCHAR, bulgarian_commander VARCHAR); CREATE TABLE battle (name VARCHAR, result VARCHAR, bulgarian_commander VARCHAR, id VARCHAR) Question: Show names, results and bulgarian commanders of the battles with no ships lost in the 'English Channel'. [/INST] SELECT name, RESULT, bulgarian_commander FROM battle EXCEPT SELECT T1.name, T1.result, T1.bulgarian_commander FROM battle AS T1 JOIN ship AS T2 ON T1.id = T2.lost_in_battle WHERE T2.location = 'English Channel' </s>
What are the notes of the death events which has substring 'East'?
CREATE TABLE death (note VARCHAR)
SELECT note FROM death WHERE note LIKE '%East%'
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE death (note VARCHAR) Question: What are the notes of the death events which has substring 'East'? [/INST] SELECT note FROM death WHERE note LIKE '%East%' </s>
what are all the addresses including line 1 and line 2?
CREATE TABLE addresses (line_1 VARCHAR, line_2 VARCHAR)
SELECT line_1, line_2 FROM addresses
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE addresses (line_1 VARCHAR, line_2 VARCHAR) Question: what are all the addresses including line 1 and line 2? [/INST] SELECT line_1, line_2 FROM addresses </s>
How many courses in total are listed?
CREATE TABLE Courses (Id VARCHAR)
SELECT COUNT(*) FROM Courses
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Courses (Id VARCHAR) Question: How many courses in total are listed? [/INST] SELECT COUNT(*) FROM Courses </s>
How is the math course described?
CREATE TABLE Courses (course_description VARCHAR, course_name VARCHAR)
SELECT course_description FROM Courses WHERE course_name = 'math'
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Courses (course_description VARCHAR, course_name VARCHAR) Question: How is the math course described? [/INST] SELECT course_description FROM Courses WHERE course_name = 'math' </s>
What is the zip code of the address in the city Port Chelsea?
CREATE TABLE Addresses (zip_postcode VARCHAR, city VARCHAR)
SELECT zip_postcode FROM Addresses WHERE city = 'Port Chelsea'
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Addresses (zip_postcode VARCHAR, city VARCHAR) Question: What is the zip code of the address in the city Port Chelsea? [/INST] SELECT zip_postcode FROM Addresses WHERE city = 'Port Chelsea' </s>
Which department offers the most number of degrees? List department name and id.
CREATE TABLE Degree_Programs (department_id VARCHAR); CREATE TABLE Departments (department_name VARCHAR, department_id VARCHAR)
SELECT TOP 1 T2.department_name, T1.department_id FROM Degree_Programs AS T1 JOIN Departments AS T2 ON T1.department_id = T2.department_id GROUP BY T1.department_id ORDER BY COUNT(*) DESC
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Degree_Programs (department_id VARCHAR); CREATE TABLE Departments (department_name VARCHAR, department_id VARCHAR) Question: Which department offers the most number of degrees? List department name and id. [/INST] SELECT TOP 1 T2.department_name, T1.department_id FROM Degree_Programs AS T1 JOIN Departments AS T2 ON T1.department_id = T2.department_id GROUP BY T1.department_id ORDER BY COUNT(*) DESC </s>
What is the name and id of the department with the most number of degrees ?
CREATE TABLE degree_programs (department_id VARCHAR); CREATE TABLE departments (department_name VARCHAR, department_id VARCHAR)
SELECT TOP 1 t2.department_name, t1.department_id FROM degree_programs AS t1 JOIN departments AS t2 ON t1.department_id = t2.department_id GROUP BY t1.department_id ORDER BY COUNT(*) DESC
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE degree_programs (department_id VARCHAR); CREATE TABLE departments (department_name VARCHAR, department_id VARCHAR) Question: What is the name and id of the department with the most number of degrees ? [/INST] SELECT TOP 1 t2.department_name, t1.department_id FROM degree_programs AS t1 JOIN departments AS t2 ON t1.department_id = t2.department_id GROUP BY t1.department_id ORDER BY COUNT(*) DESC </s>
How many departments offer any degree?
CREATE TABLE Degree_Programs (department_id VARCHAR)
SELECT COUNT(DISTINCT department_id) FROM Degree_Programs
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Degree_Programs (department_id VARCHAR) Question: How many departments offer any degree? [/INST] SELECT COUNT(DISTINCT department_id) FROM Degree_Programs </s>
How many different degree names are offered?
CREATE TABLE Degree_Programs (degree_summary_name VARCHAR)
SELECT COUNT(DISTINCT degree_summary_name) FROM Degree_Programs
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Degree_Programs (degree_summary_name VARCHAR) Question: How many different degree names are offered? [/INST] SELECT COUNT(DISTINCT degree_summary_name) FROM Degree_Programs </s>
How many degrees does the engineering department offer?
CREATE TABLE Degree_Programs (department_id VARCHAR); CREATE TABLE Departments (department_id VARCHAR, department_name VARCHAR)
SELECT COUNT(*) FROM Departments AS T1 JOIN Degree_Programs AS T2 ON T1.department_id = T2.department_id WHERE T1.department_name = 'engineer'
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Degree_Programs (department_id VARCHAR); CREATE TABLE Departments (department_id VARCHAR, department_name VARCHAR) Question: How many degrees does the engineering department offer? [/INST] SELECT COUNT(*) FROM Departments AS T1 JOIN Degree_Programs AS T2 ON T1.department_id = T2.department_id WHERE T1.department_name = 'engineer' </s>
What are the names and descriptions of all the sections?
CREATE TABLE Sections (section_name VARCHAR, section_description VARCHAR)
SELECT section_name, section_description FROM Sections
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Sections (section_name VARCHAR, section_description VARCHAR) Question: What are the names and descriptions of all the sections? [/INST] SELECT section_name, section_description FROM Sections </s>
What are the names and id of courses having at most 2 sections?
CREATE TABLE Courses (course_name VARCHAR, course_id VARCHAR); CREATE TABLE Sections (course_id VARCHAR)
SELECT T1.course_name, T1.course_id FROM Courses AS T1 JOIN Sections AS T2 ON T1.course_id = T2.course_id GROUP BY T1.course_id HAVING COUNT(*) <= 2
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Courses (course_name VARCHAR, course_id VARCHAR); CREATE TABLE Sections (course_id VARCHAR) Question: What are the names and id of courses having at most 2 sections? [/INST] SELECT T1.course_name, T1.course_id FROM Courses AS T1 JOIN Sections AS T2 ON T1.course_id = T2.course_id GROUP BY T1.course_id HAVING COUNT(*) <= 2 </s>
List the section_name in reversed lexicographical order.
CREATE TABLE Sections (section_name VARCHAR)
SELECT section_name FROM Sections ORDER BY section_name DESC
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Sections (section_name VARCHAR) Question: List the section_name in reversed lexicographical order. [/INST] SELECT section_name FROM Sections ORDER BY section_name DESC </s>
What is the semester which most student registered in? Show both the name and the id.
CREATE TABLE Student_Enrolment (semester_id VARCHAR); CREATE TABLE Semesters (semester_name VARCHAR, semester_id VARCHAR)
SELECT TOP 1 T1.semester_name, T1.semester_id FROM Semesters AS T1 JOIN Student_Enrolment AS T2 ON T1.semester_id = T2.semester_id GROUP BY T1.semester_id ORDER BY COUNT(*) DESC
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Student_Enrolment (semester_id VARCHAR); CREATE TABLE Semesters (semester_name VARCHAR, semester_id VARCHAR) Question: What is the semester which most student registered in? Show both the name and the id. [/INST] SELECT TOP 1 T1.semester_name, T1.semester_id FROM Semesters AS T1 JOIN Student_Enrolment AS T2 ON T1.semester_id = T2.semester_id GROUP BY T1.semester_id ORDER BY COUNT(*) DESC </s>
What is the description of the department whose name has the substring the computer?
CREATE TABLE Departments (department_description VARCHAR, department_name VARCHAR)
SELECT department_description FROM Departments WHERE department_name LIKE '%computer%'
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Departments (department_description VARCHAR, department_name VARCHAR) Question: What is the description of the department whose name has the substring the computer? [/INST] SELECT department_description FROM Departments WHERE department_name LIKE '%computer%' </s>
Who are enrolled in 2 degree programs in one semester? List the first name, middle name and last name and the id.
CREATE TABLE Students (first_name VARCHAR, middle_name VARCHAR, last_name VARCHAR, student_id VARCHAR); CREATE TABLE Student_Enrolment (student_id VARCHAR)
SELECT T1.first_name, T1.middle_name, T1.last_name, T1.student_id FROM Students AS T1 JOIN Student_Enrolment AS T2 ON T1.student_id = T2.student_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 Students (first_name VARCHAR, middle_name VARCHAR, last_name VARCHAR, student_id VARCHAR); CREATE TABLE Student_Enrolment (student_id VARCHAR) Question: Who are enrolled in 2 degree programs in one semester? List the first name, middle name and last name and the id. [/INST] SELECT T1.first_name, T1.middle_name, T1.last_name, T1.student_id FROM Students AS T1 JOIN Student_Enrolment AS T2 ON T1.student_id = T2.student_id GROUP BY T1.student_id HAVING COUNT(*) = 2 </s>
Who is enrolled in a Bachelor degree program? List the first name, middle name, last name.
CREATE TABLE Degree_Programs (degree_program_id VARCHAR, degree_summary_name VARCHAR); CREATE TABLE Students (first_name VARCHAR, middle_name VARCHAR, last_name VARCHAR, student_id VARCHAR); CREATE TABLE Student_Enrolment (student_id VARCHAR, degree_program_id VARCHAR)
SELECT DISTINCT T1.first_name, T1.middle_name, T1.last_name FROM Students AS T1 JOIN Student_Enrolment AS T2 ON T1.student_id = T2.student_id JOIN Degree_Programs AS T3 ON T2.degree_program_id = T3.degree_program_id WHERE T3.degree_summary_name = 'Bachelor'
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Degree_Programs (degree_program_id VARCHAR, degree_summary_name VARCHAR); CREATE TABLE Students (first_name VARCHAR, middle_name VARCHAR, last_name VARCHAR, student_id VARCHAR); CREATE TABLE Student_Enrolment (student_id VARCHAR, degree_program_id VARCHAR) Question: Who is enrolled in a Bachelor degree program? List the first name, middle name, last name. [/INST] SELECT DISTINCT T1.first_name, T1.middle_name, T1.last_name FROM Students AS T1 JOIN Student_Enrolment AS T2 ON T1.student_id = T2.student_id JOIN Degree_Programs AS T3 ON T2.degree_program_id = T3.degree_program_id WHERE T3.degree_summary_name = 'Bachelor' </s>
Find the kind of program which most number of students are enrolled in?
CREATE TABLE Student_Enrolment (degree_program_id VARCHAR); CREATE TABLE Degree_Programs (degree_summary_name VARCHAR, degree_program_id VARCHAR)
SELECT TOP 1 T1.degree_summary_name FROM Degree_Programs AS T1 JOIN Student_Enrolment AS T2 ON T1.degree_program_id = T2.degree_program_id GROUP BY T1.degree_summary_name ORDER BY COUNT(*) DESC
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Student_Enrolment (degree_program_id VARCHAR); CREATE TABLE Degree_Programs (degree_summary_name VARCHAR, degree_program_id VARCHAR) Question: Find the kind of program which most number of students are enrolled in? [/INST] SELECT TOP 1 T1.degree_summary_name FROM Degree_Programs AS T1 JOIN Student_Enrolment AS T2 ON T1.degree_program_id = T2.degree_program_id GROUP BY T1.degree_summary_name ORDER BY COUNT(*) DESC </s>
Find the program which most number of students are enrolled in. List both the id and the summary.
CREATE TABLE Degree_Programs (degree_program_id VARCHAR, degree_summary_name VARCHAR); CREATE TABLE Student_Enrolment (degree_program_id VARCHAR)
SELECT TOP 1 T1.degree_program_id, T1.degree_summary_name FROM Degree_Programs AS T1 JOIN Student_Enrolment AS T2 ON T1.degree_program_id = T2.degree_program_id GROUP BY T1.degree_program_id ORDER BY COUNT(*) DESC
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Degree_Programs (degree_program_id VARCHAR, degree_summary_name VARCHAR); CREATE TABLE Student_Enrolment (degree_program_id VARCHAR) Question: Find the program which most number of students are enrolled in. List both the id and the summary. [/INST] SELECT TOP 1 T1.degree_program_id, T1.degree_summary_name FROM Degree_Programs AS T1 JOIN Student_Enrolment AS T2 ON T1.degree_program_id = T2.degree_program_id GROUP BY T1.degree_program_id ORDER BY COUNT(*) DESC </s>
Which student has enrolled for the most times in any program? List the id, first name, middle name, last name, the number of enrollments and student id.
CREATE TABLE Students (student_id VARCHAR, first_name VARCHAR, middle_name VARCHAR, last_name VARCHAR); CREATE TABLE Student_Enrolment (student_id VARCHAR)
SELECT TOP 1 T1.student_id, T1.first_name, T1.middle_name, T1.last_name, COUNT(*), T1.student_id FROM Students AS T1 JOIN Student_Enrolment AS T2 ON T1.student_id = T2.student_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 Students (student_id VARCHAR, first_name VARCHAR, middle_name VARCHAR, last_name VARCHAR); CREATE TABLE Student_Enrolment (student_id VARCHAR) Question: Which student has enrolled for the most times in any program? List the id, first name, middle name, last name, the number of enrollments and student id. [/INST] SELECT TOP 1 T1.student_id, T1.first_name, T1.middle_name, T1.last_name, COUNT(*), T1.student_id FROM Students AS T1 JOIN Student_Enrolment AS T2 ON T1.student_id = T2.student_id GROUP BY T1.student_id ORDER BY COUNT(*) DESC </s>
Which semesters do not have any student enrolled? List the semester name.
CREATE TABLE Student_Enrolment (semester_name VARCHAR, semester_id VARCHAR); CREATE TABLE Semesters (semester_name VARCHAR, semester_id VARCHAR)
SELECT semester_name FROM Semesters WHERE NOT semester_id IN (SELECT semester_id FROM Student_Enrolment)
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Student_Enrolment (semester_name VARCHAR, semester_id VARCHAR); CREATE TABLE Semesters (semester_name VARCHAR, semester_id VARCHAR) Question: Which semesters do not have any student enrolled? List the semester name. [/INST] SELECT semester_name FROM Semesters WHERE NOT semester_id IN (SELECT semester_id FROM Student_Enrolment) </s>
What are all the course names of the courses which ever have students enrolled in?
CREATE TABLE Courses (course_name VARCHAR, course_id VARCHAR); CREATE TABLE Student_Enrolment_Courses (course_id VARCHAR)
SELECT DISTINCT T1.course_name FROM Courses AS T1 JOIN Student_Enrolment_Courses AS T2 ON T1.course_id = T2.course_id
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Courses (course_name VARCHAR, course_id VARCHAR); CREATE TABLE Student_Enrolment_Courses (course_id VARCHAR) Question: What are all the course names of the courses which ever have students enrolled in? [/INST] SELECT DISTINCT T1.course_name FROM Courses AS T1 JOIN Student_Enrolment_Courses AS T2 ON T1.course_id = T2.course_id </s>
What's the name of the course with most number of enrollments?
CREATE TABLE Courses (course_name VARCHAR, course_id VARCHAR); CREATE TABLE Student_Enrolment_Courses (course_id VARCHAR)
SELECT TOP 1 T1.course_name FROM Courses AS T1 JOIN Student_Enrolment_Courses AS T2 ON T1.course_id = T2.course_id GROUP BY T1.course_name ORDER BY COUNT(*) DESC
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Courses (course_name VARCHAR, course_id VARCHAR); CREATE TABLE Student_Enrolment_Courses (course_id VARCHAR) Question: What's the name of the course with most number of enrollments? [/INST] SELECT TOP 1 T1.course_name FROM Courses AS T1 JOIN Student_Enrolment_Courses AS T2 ON T1.course_id = T2.course_id GROUP BY T1.course_name ORDER BY COUNT(*) DESC </s>
Find the last name of the students who currently live in the state of North Carolina but have not registered in any degree program.
CREATE TABLE Addresses (address_id VARCHAR, state_province_county VARCHAR); CREATE TABLE Students (last_name VARCHAR, current_address_id VARCHAR); CREATE TABLE Students (last_name VARCHAR, student_id VARCHAR); CREATE TABLE Student_Enrolment (student_id VARCHAR)
SELECT T1.last_name FROM Students AS T1 JOIN Addresses AS T2 ON T1.current_address_id = T2.address_id WHERE T2.state_province_county = 'NorthCarolina' EXCEPT SELECT DISTINCT T3.last_name FROM Students AS T3 JOIN Student_Enrolment AS T4 ON T3.student_id = T4.student_id
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Addresses (address_id VARCHAR, state_province_county VARCHAR); CREATE TABLE Students (last_name VARCHAR, current_address_id VARCHAR); CREATE TABLE Students (last_name VARCHAR, student_id VARCHAR); CREATE TABLE Student_Enrolment (student_id VARCHAR) Question: Find the last name of the students who currently live in the state of North Carolina but have not registered in any degree program. [/INST] SELECT T1.last_name FROM Students AS T1 JOIN Addresses AS T2 ON T1.current_address_id = T2.address_id WHERE T2.state_province_county = 'NorthCarolina' EXCEPT SELECT DISTINCT T3.last_name FROM Students AS T3 JOIN Student_Enrolment AS T4 ON T3.student_id = T4.student_id </s>
Show the date and id of the transcript with at least 2 course results.
CREATE TABLE Transcript_Contents (transcript_id VARCHAR); CREATE TABLE Transcripts (transcript_date VARCHAR, transcript_id VARCHAR)
SELECT T2.transcript_date, T1.transcript_id FROM Transcript_Contents AS T1 JOIN Transcripts AS T2 ON T1.transcript_id = T2.transcript_id GROUP BY T1.transcript_id HAVING COUNT(*) >= 2
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Transcript_Contents (transcript_id VARCHAR); CREATE TABLE Transcripts (transcript_date VARCHAR, transcript_id VARCHAR) Question: Show the date and id of the transcript with at least 2 course results. [/INST] SELECT T2.transcript_date, T1.transcript_id FROM Transcript_Contents AS T1 JOIN Transcripts AS T2 ON T1.transcript_id = T2.transcript_id GROUP BY T1.transcript_id HAVING COUNT(*) >= 2 </s>
What is the phone number of the man with the first name Timmothy and the last name Ward?
CREATE TABLE Students (cell_mobile_number VARCHAR, first_name VARCHAR, last_name VARCHAR)
SELECT cell_mobile_number FROM Students WHERE first_name = 'Timmothy' AND last_name = 'Ward'
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Students (cell_mobile_number VARCHAR, first_name VARCHAR, last_name VARCHAR) Question: What is the phone number of the man with the first name Timmothy and the last name Ward? [/INST] SELECT cell_mobile_number FROM Students WHERE first_name = 'Timmothy' AND last_name = 'Ward' </s>
What is the mobile phone number of the student named Timmothy Ward ?
CREATE TABLE students (cell_mobile_number VARCHAR, first_name VARCHAR, last_name VARCHAR)
SELECT cell_mobile_number FROM students WHERE first_name = 'timmothy' AND last_name = 'ward'
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE students (cell_mobile_number VARCHAR, first_name VARCHAR, last_name VARCHAR) Question: What is the mobile phone number of the student named Timmothy Ward ? [/INST] SELECT cell_mobile_number FROM students WHERE first_name = 'timmothy' AND last_name = 'ward' </s>
Who is the first student to register? List the first name, middle name and last name.
CREATE TABLE Students (first_name VARCHAR, middle_name VARCHAR, last_name VARCHAR, date_first_registered VARCHAR)
SELECT TOP 1 first_name, middle_name, last_name FROM Students ORDER BY date_first_registered
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Students (first_name VARCHAR, middle_name VARCHAR, last_name VARCHAR, date_first_registered VARCHAR) Question: Who is the first student to register? List the first name, middle name and last name. [/INST] SELECT TOP 1 first_name, middle_name, last_name FROM Students ORDER BY date_first_registered </s>
Who is the earliest graduate of the school? List the first name, middle name and last name.
CREATE TABLE Students (first_name VARCHAR, middle_name VARCHAR, last_name VARCHAR, date_left VARCHAR)
SELECT TOP 1 first_name, middle_name, last_name FROM Students ORDER BY date_left
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Students (first_name VARCHAR, middle_name VARCHAR, last_name VARCHAR, date_left VARCHAR) Question: Who is the earliest graduate of the school? List the first name, middle name and last name. [/INST] SELECT TOP 1 first_name, middle_name, last_name FROM Students ORDER BY date_left </s>
Whose permanent address is different from his or her current address? List his or her first name.
CREATE TABLE Students (first_name VARCHAR, current_address_id VARCHAR, permanent_address_id VARCHAR)
SELECT first_name FROM Students WHERE current_address_id <> permanent_address_id
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Students (first_name VARCHAR, current_address_id VARCHAR, permanent_address_id VARCHAR) Question: Whose permanent address is different from his or her current address? List his or her first name. [/INST] SELECT first_name FROM Students WHERE current_address_id <> permanent_address_id </s>
Which address holds the most number of students currently? List the address id and all lines.
CREATE TABLE Addresses (address_id VARCHAR, line_1 VARCHAR, line_2 VARCHAR); CREATE TABLE Students (current_address_id VARCHAR)
SELECT TOP 1 T1.address_id, T1.line_1, T1.line_2 FROM Addresses AS T1 JOIN Students AS T2 ON T1.address_id = T2.current_address_id GROUP BY T1.address_id ORDER BY COUNT(*) DESC
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Addresses (address_id VARCHAR, line_1 VARCHAR, line_2 VARCHAR); CREATE TABLE Students (current_address_id VARCHAR) Question: Which address holds the most number of students currently? List the address id and all lines. [/INST] SELECT TOP 1 T1.address_id, T1.line_1, T1.line_2 FROM Addresses AS T1 JOIN Students AS T2 ON T1.address_id = T2.current_address_id GROUP BY T1.address_id ORDER BY COUNT(*) DESC </s>
On average, when were the transcripts printed?
CREATE TABLE Transcripts (transcript_date INTEGER)
SELECT AVG(transcript_date) FROM Transcripts
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Transcripts (transcript_date INTEGER) Question: On average, when were the transcripts printed? [/INST] SELECT AVG(transcript_date) FROM Transcripts </s>
When is the first transcript released? List the date and details.
CREATE TABLE Transcripts (transcript_date VARCHAR, other_details VARCHAR)
SELECT TOP 1 transcript_date, other_details FROM Transcripts ORDER BY transcript_date
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Transcripts (transcript_date VARCHAR, other_details VARCHAR) Question: When is the first transcript released? List the date and details. [/INST] SELECT TOP 1 transcript_date, other_details FROM Transcripts ORDER BY transcript_date </s>
How many transcripts are released?
CREATE TABLE Transcripts (Id VARCHAR)
SELECT COUNT(*) FROM Transcripts
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Transcripts (Id VARCHAR) Question: How many transcripts are released? [/INST] SELECT COUNT(*) FROM Transcripts </s>
What is the last transcript release date?
CREATE TABLE Transcripts (transcript_date VARCHAR)
SELECT TOP 1 transcript_date FROM Transcripts ORDER BY transcript_date DESC
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Transcripts (transcript_date VARCHAR) Question: What is the last transcript release date? [/INST] SELECT TOP 1 transcript_date FROM Transcripts ORDER BY transcript_date DESC </s>
How many times at most can a course enrollment result show in different transcripts? Also show the course enrollment id.
CREATE TABLE Transcript_Contents (student_course_id VARCHAR)
SELECT TOP 1 COUNT(*), student_course_id FROM Transcript_Contents GROUP BY student_course_id ORDER BY COUNT(*) DESC
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Transcript_Contents (student_course_id VARCHAR) Question: How many times at most can a course enrollment result show in different transcripts? Also show the course enrollment id. [/INST] SELECT TOP 1 COUNT(*), student_course_id FROM Transcript_Contents GROUP BY student_course_id ORDER BY COUNT(*) DESC </s>
Show the date of the transcript which shows the least number of results, also list the id.
CREATE TABLE Transcript_Contents (transcript_id VARCHAR); CREATE TABLE Transcripts (transcript_date VARCHAR, transcript_id VARCHAR)
SELECT TOP 1 T2.transcript_date, T1.transcript_id FROM Transcript_Contents AS T1 JOIN Transcripts AS T2 ON T1.transcript_id = T2.transcript_id GROUP BY T1.transcript_id ORDER BY COUNT(*)
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Transcript_Contents (transcript_id VARCHAR); CREATE TABLE Transcripts (transcript_date VARCHAR, transcript_id VARCHAR) Question: Show the date of the transcript which shows the least number of results, also list the id. [/INST] SELECT TOP 1 T2.transcript_date, T1.transcript_id FROM Transcript_Contents AS T1 JOIN Transcripts AS T2 ON T1.transcript_id = T2.transcript_id GROUP BY T1.transcript_id ORDER BY COUNT(*) </s>
Find the semester when both Master students and Bachelor students got enrolled in.
CREATE TABLE Degree_Programs (degree_program_id VARCHAR); CREATE TABLE Student_Enrolment (semester_id VARCHAR, degree_program_id VARCHAR)
SELECT DISTINCT T2.semester_id FROM Degree_Programs AS T1 JOIN Student_Enrolment AS T2 ON T1.degree_program_id = T2.degree_program_id WHERE degree_summary_name = 'Master' INTERSECT SELECT DISTINCT T2.semester_id FROM Degree_Programs AS T1 JOIN Student_Enrolment AS T2 ON T1.degree_program_id = T2.degree_program_id WHERE degree_summary_name = 'Bachelor'
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Degree_Programs (degree_program_id VARCHAR); CREATE TABLE Student_Enrolment (semester_id VARCHAR, degree_program_id VARCHAR) Question: Find the semester when both Master students and Bachelor students got enrolled in. [/INST] SELECT DISTINCT T2.semester_id FROM Degree_Programs AS T1 JOIN Student_Enrolment AS T2 ON T1.degree_program_id = T2.degree_program_id WHERE degree_summary_name = 'Master' INTERSECT SELECT DISTINCT T2.semester_id FROM Degree_Programs AS T1 JOIN Student_Enrolment AS T2 ON T1.degree_program_id = T2.degree_program_id WHERE degree_summary_name = 'Bachelor' </s>
How many different addresses do the students currently live?
CREATE TABLE Students (current_address_id VARCHAR)
SELECT COUNT(DISTINCT current_address_id) FROM Students
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Students (current_address_id VARCHAR) Question: How many different addresses do the students currently live? [/INST] SELECT COUNT(DISTINCT current_address_id) FROM Students </s>
List all the student details in reversed lexicographical order.
CREATE TABLE Students (other_student_details VARCHAR)
SELECT other_student_details FROM Students ORDER BY other_student_details DESC
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Students (other_student_details VARCHAR) Question: List all the student details in reversed lexicographical order. [/INST] SELECT other_student_details FROM Students ORDER BY other_student_details DESC </s>
Describe the section h.
CREATE TABLE Sections (section_description VARCHAR, section_name VARCHAR)
SELECT section_description FROM Sections WHERE section_name = 'h'
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Sections (section_description VARCHAR, section_name VARCHAR) Question: Describe the section h. [/INST] SELECT section_description FROM Sections WHERE section_name = 'h' </s>
Find the first name of the students who permanently live in the country Haiti or have the cell phone number 09700166582 .
CREATE TABLE students (first_name VARCHAR, permanent_address_id VARCHAR, cell_mobile_number VARCHAR); CREATE TABLE addresses (address_id VARCHAR, country VARCHAR)
SELECT t1.first_name FROM students AS t1 JOIN addresses AS t2 ON t1.permanent_address_id = t2.address_id WHERE t2.country = 'haiti' OR t1.cell_mobile_number = '09700166582'
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE students (first_name VARCHAR, permanent_address_id VARCHAR, cell_mobile_number VARCHAR); CREATE TABLE addresses (address_id VARCHAR, country VARCHAR) Question: Find the first name of the students who permanently live in the country Haiti or have the cell phone number 09700166582 . [/INST] SELECT t1.first_name FROM students AS t1 JOIN addresses AS t2 ON t1.permanent_address_id = t2.address_id WHERE t2.country = 'haiti' OR t1.cell_mobile_number = '09700166582' </s>
List the title of all cartoons in alphabetical order.
CREATE TABLE Cartoon (Title VARCHAR, title VARCHAR)
SELECT Title FROM Cartoon ORDER BY title
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Cartoon (Title VARCHAR, title VARCHAR) Question: List the title of all cartoons in alphabetical order. [/INST] SELECT Title FROM Cartoon ORDER BY title </s>
List all cartoon directed by "Ben Jones".
CREATE TABLE Cartoon (Title VARCHAR, Directed_by VARCHAR)
SELECT Title FROM Cartoon WHERE Directed_by = "Ben Jones"
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Cartoon (Title VARCHAR, Directed_by VARCHAR) Question: List all cartoon directed by "Ben Jones". [/INST] SELECT Title FROM Cartoon WHERE Directed_by = "Ben Jones" </s>
How many cartoons were written by "Joseph Kuhr"?
CREATE TABLE Cartoon (Written_by VARCHAR)
SELECT COUNT(*) FROM Cartoon WHERE Written_by = "Joseph Kuhr"
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Cartoon (Written_by VARCHAR) Question: How many cartoons were written by "Joseph Kuhr"? [/INST] SELECT COUNT(*) FROM Cartoon WHERE Written_by = "Joseph Kuhr" </s>
list all cartoon titles and their directors ordered by their air date
CREATE TABLE Cartoon (title VARCHAR, Directed_by VARCHAR, Original_air_date VARCHAR)
SELECT title, Directed_by FROM Cartoon ORDER BY Original_air_date
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Cartoon (title VARCHAR, Directed_by VARCHAR, Original_air_date VARCHAR) Question: list all cartoon titles and their directors ordered by their air date [/INST] SELECT title, Directed_by FROM Cartoon ORDER BY Original_air_date </s>
List the title of all cartoon directed by "Ben Jones" or "Brandon Vietti".
CREATE TABLE Cartoon (Title VARCHAR, Directed_by VARCHAR)
SELECT Title FROM Cartoon WHERE Directed_by = "Ben Jones" OR Directed_by = "Brandon Vietti"
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Cartoon (Title VARCHAR, Directed_by VARCHAR) Question: List the title of all cartoon directed by "Ben Jones" or "Brandon Vietti". [/INST] SELECT Title FROM Cartoon WHERE Directed_by = "Ben Jones" OR Directed_by = "Brandon Vietti" </s>
Which country has the most of TV Channels? List the country and number of TV Channels it has.
CREATE TABLE TV_Channel (Country VARCHAR)
SELECT TOP 1 Country, COUNT(*) FROM TV_Channel GROUP BY Country ORDER BY COUNT(*) DESC
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE TV_Channel (Country VARCHAR) Question: Which country has the most of TV Channels? List the country and number of TV Channels it has. [/INST] SELECT TOP 1 Country, COUNT(*) FROM TV_Channel GROUP BY Country ORDER BY COUNT(*) DESC </s>
List the number of different series names and contents in the TV Channel table.
CREATE TABLE TV_Channel (series_name VARCHAR, content VARCHAR)
SELECT COUNT(DISTINCT series_name), COUNT(DISTINCT content) FROM TV_Channel
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE TV_Channel (series_name VARCHAR, content VARCHAR) Question: List the number of different series names and contents in the TV Channel table. [/INST] SELECT COUNT(DISTINCT series_name), COUNT(DISTINCT content) FROM TV_Channel </s>
What is the content of TV Channel with serial name "Sky Radio"?
CREATE TABLE TV_Channel (Content VARCHAR, series_name VARCHAR)
SELECT Content FROM TV_Channel WHERE series_name = "Sky Radio"
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE TV_Channel (Content VARCHAR, series_name VARCHAR) Question: What is the content of TV Channel with serial name "Sky Radio"? [/INST] SELECT Content FROM TV_Channel WHERE series_name = "Sky Radio" </s>
What is the Package Option of TV Channel with serial name "Sky Radio"?
CREATE TABLE TV_Channel (Package_Option VARCHAR, series_name VARCHAR)
SELECT Package_Option FROM TV_Channel WHERE series_name = "Sky Radio"
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE TV_Channel (Package_Option VARCHAR, series_name VARCHAR) Question: What is the Package Option of TV Channel with serial name "Sky Radio"? [/INST] SELECT Package_Option FROM TV_Channel WHERE series_name = "Sky Radio" </s>
How many TV Channel using language English?
CREATE TABLE TV_Channel (LANGUAGE VARCHAR)
SELECT COUNT(*) FROM TV_Channel WHERE LANGUAGE = "English"
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE TV_Channel (LANGUAGE VARCHAR) Question: How many TV Channel using language English? [/INST] SELECT COUNT(*) FROM TV_Channel WHERE LANGUAGE = "English" </s>
List the language used least number of TV Channel. List language and number of TV Channel.
CREATE TABLE TV_Channel (LANGUAGE VARCHAR)
SELECT TOP 1 LANGUAGE, COUNT(*) FROM TV_Channel GROUP BY LANGUAGE ORDER BY COUNT(*)
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE TV_Channel (LANGUAGE VARCHAR) Question: List the language used least number of TV Channel. List language and number of TV Channel. [/INST] SELECT TOP 1 LANGUAGE, COUNT(*) FROM TV_Channel GROUP BY LANGUAGE ORDER BY COUNT(*) </s>
List each language and the number of TV Channels using it.
CREATE TABLE TV_Channel (LANGUAGE VARCHAR)
SELECT LANGUAGE, COUNT(*) FROM TV_Channel GROUP BY LANGUAGE
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE TV_Channel (LANGUAGE VARCHAR) Question: List each language and the number of TV Channels using it. [/INST] SELECT LANGUAGE, COUNT(*) FROM TV_Channel GROUP BY LANGUAGE </s>
What is the TV Channel that shows the cartoon "The Rise of the Blue Beetle!"? List the TV Channel's series name.
CREATE TABLE Cartoon (Channel VARCHAR, Title VARCHAR); CREATE TABLE TV_Channel (series_name VARCHAR, id VARCHAR)
SELECT T1.series_name FROM TV_Channel AS T1 JOIN Cartoon AS T2 ON T1.id = T2.Channel WHERE T2.Title = "The Rise of the Blue Beetle!"
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Cartoon (Channel VARCHAR, Title VARCHAR); CREATE TABLE TV_Channel (series_name VARCHAR, id VARCHAR) Question: What is the TV Channel that shows the cartoon "The Rise of the Blue Beetle!"? List the TV Channel's series name. [/INST] SELECT T1.series_name FROM TV_Channel AS T1 JOIN Cartoon AS T2 ON T1.id = T2.Channel WHERE T2.Title = "The Rise of the Blue Beetle!" </s>
List the title of all Cartoons showed on TV Channel with series name "Sky Radio".
CREATE TABLE Cartoon (Title VARCHAR, Channel VARCHAR); CREATE TABLE TV_Channel (id VARCHAR, series_name VARCHAR)
SELECT T2.Title FROM TV_Channel AS T1 JOIN Cartoon AS T2 ON T1.id = T2.Channel WHERE T1.series_name = "Sky Radio"
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Cartoon (Title VARCHAR, Channel VARCHAR); CREATE TABLE TV_Channel (id VARCHAR, series_name VARCHAR) Question: List the title of all Cartoons showed on TV Channel with series name "Sky Radio". [/INST] SELECT T2.Title FROM TV_Channel AS T1 JOIN Cartoon AS T2 ON T1.id = T2.Channel WHERE T1.series_name = "Sky Radio" </s>
List the Episode of all TV series sorted by rating.
CREATE TABLE TV_series (Episode VARCHAR, rating VARCHAR)
SELECT Episode FROM TV_series ORDER BY rating
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE TV_series (Episode VARCHAR, rating VARCHAR) Question: List the Episode of all TV series sorted by rating. [/INST] SELECT Episode FROM TV_series ORDER BY rating </s>
List top 3 highest Rating TV series. List the TV series's Episode and Rating.
CREATE TABLE TV_series (Episode VARCHAR, Rating VARCHAR)
SELECT TOP 3 Episode, Rating FROM TV_series ORDER BY Rating DESC
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE TV_series (Episode VARCHAR, Rating VARCHAR) Question: List top 3 highest Rating TV series. List the TV series's Episode and Rating. [/INST] SELECT TOP 3 Episode, Rating FROM TV_series ORDER BY Rating DESC </s>
What is minimum and maximum share of TV series?
CREATE TABLE TV_series (SHARE INTEGER)
SELECT MAX(SHARE), MIN(SHARE) FROM TV_series
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE TV_series (SHARE INTEGER) Question: What is minimum and maximum share of TV series? [/INST] SELECT MAX(SHARE), MIN(SHARE) FROM TV_series </s>
What is the air date of TV series with Episode "A Love of a Lifetime"?
CREATE TABLE TV_series (Air_Date VARCHAR, Episode VARCHAR)
SELECT Air_Date FROM TV_series WHERE Episode = "A Love of a Lifetime"
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE TV_series (Air_Date VARCHAR, Episode VARCHAR) Question: What is the air date of TV series with Episode "A Love of a Lifetime"? [/INST] SELECT Air_Date FROM TV_series WHERE Episode = "A Love of a Lifetime" </s>
What is Weekly Rank of TV series with Episode "A Love of a Lifetime"?
CREATE TABLE TV_series (Weekly_Rank VARCHAR, Episode VARCHAR)
SELECT Weekly_Rank FROM TV_series WHERE Episode = "A Love of a Lifetime"
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE TV_series (Weekly_Rank VARCHAR, Episode VARCHAR) Question: What is Weekly Rank of TV series with Episode "A Love of a Lifetime"? [/INST] SELECT Weekly_Rank FROM TV_series WHERE Episode = "A Love of a Lifetime" </s>
What is the TV Channel of TV series with Episode "A Love of a Lifetime"? List the TV Channel's series name.
CREATE TABLE TV_series (Channel VARCHAR, Episode VARCHAR); CREATE TABLE TV_Channel (series_name VARCHAR, id VARCHAR)
SELECT T1.series_name FROM TV_Channel AS T1 JOIN TV_series AS T2 ON T1.id = T2.Channel WHERE T2.Episode = "A Love of a Lifetime"
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE TV_series (Channel VARCHAR, Episode VARCHAR); CREATE TABLE TV_Channel (series_name VARCHAR, id VARCHAR) Question: What is the TV Channel of TV series with Episode "A Love of a Lifetime"? List the TV Channel's series name. [/INST] SELECT T1.series_name FROM TV_Channel AS T1 JOIN TV_series AS T2 ON T1.id = T2.Channel WHERE T2.Episode = "A Love of a Lifetime" </s>