instruction
stringlengths
12
244
input
stringlengths
27
489
output
stringlengths
18
557
text
stringlengths
194
1.14k
Find the first name of the band mate that has performed in most songs.
CREATE TABLE Songs (SongId VARCHAR); CREATE TABLE Band (firstname VARCHAR, id VARCHAR); CREATE TABLE Performance (bandmate VARCHAR)
SELECT TOP 1 t2.firstname FROM Performance AS t1 JOIN Band AS t2 ON t1.bandmate = t2.id JOIN Songs AS T3 ON T3.SongId = T1.SongId GROUP BY firstname ORDER BY COUNT(*) DESC
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Songs (SongId VARCHAR); CREATE TABLE Band (firstname VARCHAR, id VARCHAR); CREATE TABLE Performance (bandmate VARCHAR) Question: Find the first name of the band mate that has performed in most songs. [/INST] SELECT TOP 1 t2.firstname FROM Performance AS t1 JOIN Band AS t2 ON t1.bandmate = t2.id JOIN Songs AS T3 ON T3.SongId = T1.SongId GROUP BY firstname ORDER BY COUNT(*) DESC </s>
Which vocal type has the band mate with first name "Marianne" played the most?
CREATE TABLE vocals (bandmate VARCHAR); CREATE TABLE band (id VARCHAR)
SELECT TOP 1 TYPE FROM vocals AS T1 JOIN band AS T2 ON T1.bandmate = T2.id WHERE firstname = "Marianne" GROUP BY TYPE ORDER BY COUNT(*) DESC
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE vocals (bandmate VARCHAR); CREATE TABLE band (id VARCHAR) Question: Which vocal type has the band mate with first name "Marianne" played the most? [/INST] SELECT TOP 1 TYPE FROM vocals AS T1 JOIN band AS T2 ON T1.bandmate = T2.id WHERE firstname = "Marianne" GROUP BY TYPE ORDER BY COUNT(*) DESC </s>
Who is performing in the back stage position for the song "Der Kapitan"? Show the first name and last name.
CREATE TABLE Band (firstname VARCHAR, lastname VARCHAR, id VARCHAR); CREATE TABLE Performance (bandmate VARCHAR, SongId VARCHAR, StagePosition VARCHAR); CREATE TABLE Songs (SongId VARCHAR, Title VARCHAR)
SELECT T2.firstname, T2.lastname FROM Performance AS T1 JOIN Band AS T2 ON T1.bandmate = T2.id JOIN Songs AS T3 ON T3.SongId = T1.SongId WHERE T3.Title = "Der Kapitan" AND T1.StagePosition = "back"
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Band (firstname VARCHAR, lastname VARCHAR, id VARCHAR); CREATE TABLE Performance (bandmate VARCHAR, SongId VARCHAR, StagePosition VARCHAR); CREATE TABLE Songs (SongId VARCHAR, Title VARCHAR) Question: Who is performing in the back stage position for the song "Der Kapitan"? Show the first name and last name. [/INST] SELECT T2.firstname, T2.lastname FROM Performance AS T1 JOIN Band AS T2 ON T1.bandmate = T2.id JOIN Songs AS T3 ON T3.SongId = T1.SongId WHERE T3.Title = "Der Kapitan" AND T1.StagePosition = "back" </s>
What are the songs in album "A Kiss Before You Go: Live in Hamburg"?
CREATE TABLE songs (title VARCHAR, songid VARCHAR); CREATE TABLE albums (aid VARCHAR, title VARCHAR); CREATE TABLE tracklists (albumid VARCHAR, songid VARCHAR)
SELECT T3.title FROM albums AS T1 JOIN tracklists AS T2 ON T1.aid = T2.albumid JOIN songs AS T3 ON T2.songid = T3.songid WHERE T1.title = "A Kiss Before You Go: Live in Hamburg"
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE songs (title VARCHAR, songid VARCHAR); CREATE TABLE albums (aid VARCHAR, title VARCHAR); CREATE TABLE tracklists (albumid VARCHAR, songid VARCHAR) Question: What are the songs in album "A Kiss Before You Go: Live in Hamburg"? [/INST] SELECT T3.title FROM albums AS T1 JOIN tracklists AS T2 ON T1.aid = T2.albumid JOIN songs AS T3 ON T2.songid = T3.songid WHERE T1.title = "A Kiss Before You Go: Live in Hamburg" </s>
What are all the songs in albums under label "Universal Music Group"?
CREATE TABLE songs (title VARCHAR, songid VARCHAR); CREATE TABLE albums (aid VARCHAR); CREATE TABLE tracklists (albumid VARCHAR, songid VARCHAR)
SELECT T3.title FROM albums AS T1 JOIN tracklists AS T2 ON T1.aid = T2.albumid JOIN songs AS T3 ON T2.songid = T3.songid WHERE t1.label = "Universal Music Group"
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE songs (title VARCHAR, songid VARCHAR); CREATE TABLE albums (aid VARCHAR); CREATE TABLE tracklists (albumid VARCHAR, songid VARCHAR) Question: What are all the songs in albums under label "Universal Music Group"? [/INST] SELECT T3.title FROM albums AS T1 JOIN tracklists AS T2 ON T1.aid = T2.albumid JOIN songs AS T3 ON T2.songid = T3.songid WHERE t1.label = "Universal Music Group" </s>
Find the number of songs in all the studio albums.
CREATE TABLE songs (title VARCHAR, songid VARCHAR); CREATE TABLE albums (aid VARCHAR); CREATE TABLE tracklists (albumid VARCHAR, songid VARCHAR)
SELECT COUNT(DISTINCT T3.title) FROM albums AS T1 JOIN tracklists AS T2 ON T1.aid = T2.albumid JOIN songs AS T3 ON T2.songid = T3.songid WHERE t1.type = "Studio"
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE songs (title VARCHAR, songid VARCHAR); CREATE TABLE albums (aid VARCHAR); CREATE TABLE tracklists (albumid VARCHAR, songid VARCHAR) Question: Find the number of songs in all the studio albums. [/INST] SELECT COUNT(DISTINCT T3.title) FROM albums AS T1 JOIN tracklists AS T2 ON T1.aid = T2.albumid JOIN songs AS T3 ON T2.songid = T3.songid WHERE t1.type = "Studio" </s>
Who is the founder of Sony?
CREATE TABLE manufacturers (founder VARCHAR, name VARCHAR)
SELECT founder FROM manufacturers WHERE name = 'Sony'
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE manufacturers (founder VARCHAR, name VARCHAR) Question: Who is the founder of Sony? [/INST] SELECT founder FROM manufacturers WHERE name = 'Sony' </s>
Where is the headquarter of the company founded by James?
CREATE TABLE manufacturers (headquarter VARCHAR, founder VARCHAR)
SELECT headquarter FROM manufacturers WHERE founder = 'James'
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE manufacturers (headquarter VARCHAR, founder VARCHAR) Question: Where is the headquarter of the company founded by James? [/INST] SELECT headquarter FROM manufacturers WHERE founder = 'James' </s>
Find all manufacturers' names and their headquarters, sorted by the ones with highest revenue first.
CREATE TABLE manufacturers (name VARCHAR, headquarter VARCHAR, revenue VARCHAR)
SELECT name, headquarter FROM manufacturers ORDER BY revenue DESC
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE manufacturers (name VARCHAR, headquarter VARCHAR, revenue VARCHAR) Question: Find all manufacturers' names and their headquarters, sorted by the ones with highest revenue first. [/INST] SELECT name, headquarter FROM manufacturers ORDER BY revenue DESC </s>
What are the average, maximum and total revenues of all companies?
CREATE TABLE manufacturers (revenue INTEGER)
SELECT AVG(revenue), MAX(revenue), SUM(revenue) FROM manufacturers
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE manufacturers (revenue INTEGER) Question: What are the average, maximum and total revenues of all companies? [/INST] SELECT AVG(revenue), MAX(revenue), SUM(revenue) FROM manufacturers </s>
How many companies were created by Andy?
CREATE TABLE manufacturers (founder VARCHAR)
SELECT COUNT(*) FROM manufacturers WHERE founder = 'Andy'
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE manufacturers (founder VARCHAR) Question: How many companies were created by Andy? [/INST] SELECT COUNT(*) FROM manufacturers WHERE founder = 'Andy' </s>
Find the total revenue created by the companies whose headquarter is located at Austin.
CREATE TABLE manufacturers (revenue INTEGER, headquarter VARCHAR)
SELECT SUM(revenue) FROM manufacturers WHERE headquarter = 'Austin'
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE manufacturers (revenue INTEGER, headquarter VARCHAR) Question: Find the total revenue created by the companies whose headquarter is located at Austin. [/INST] SELECT SUM(revenue) FROM manufacturers WHERE headquarter = 'Austin' </s>
What are the different cities listed?
CREATE TABLE manufacturers (headquarter VARCHAR)
SELECT DISTINCT headquarter FROM manufacturers
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE manufacturers (headquarter VARCHAR) Question: What are the different cities listed? [/INST] SELECT DISTINCT headquarter FROM manufacturers </s>
Find the number of manufactures that are based in Tokyo or Beijing.
CREATE TABLE manufacturers (headquarter VARCHAR)
SELECT COUNT(*) FROM manufacturers WHERE headquarter = 'Tokyo' OR headquarter = 'Beijing'
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE manufacturers (headquarter VARCHAR) Question: Find the number of manufactures that are based in Tokyo or Beijing. [/INST] SELECT COUNT(*) FROM manufacturers WHERE headquarter = 'Tokyo' OR headquarter = 'Beijing' </s>
Find the founder of the company whose name begins with the letter 'S'.
CREATE TABLE manufacturers (founder VARCHAR, name VARCHAR)
SELECT founder FROM manufacturers WHERE name LIKE 'S%'
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE manufacturers (founder VARCHAR, name VARCHAR) Question: Find the founder of the company whose name begins with the letter 'S'. [/INST] SELECT founder FROM manufacturers WHERE name LIKE 'S%' </s>
Find the name of companies whose revenue is between 100 and 150.
CREATE TABLE manufacturers (name VARCHAR, revenue INTEGER)
SELECT name FROM manufacturers WHERE revenue BETWEEN 100 AND 150
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE manufacturers (name VARCHAR, revenue INTEGER) Question: Find the name of companies whose revenue is between 100 and 150. [/INST] SELECT name FROM manufacturers WHERE revenue BETWEEN 100 AND 150 </s>
What is the total revenue of all companies whose main office is at Tokyo or Taiwan?
CREATE TABLE manufacturers (revenue INTEGER, Headquarter VARCHAR)
SELECT SUM(revenue) FROM manufacturers WHERE Headquarter = 'Tokyo' OR Headquarter = 'Taiwan'
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE manufacturers (revenue INTEGER, Headquarter VARCHAR) Question: What is the total revenue of all companies whose main office is at Tokyo or Taiwan? [/INST] SELECT SUM(revenue) FROM manufacturers WHERE Headquarter = 'Tokyo' OR Headquarter = 'Taiwan' </s>
Find the name of product that is produced by both companies Creative Labs and Sony.
CREATE TABLE manufacturers (code VARCHAR, name VARCHAR); CREATE TABLE products (name VARCHAR, Manufacturer VARCHAR)
SELECT T1.name FROM products AS T1 JOIN manufacturers AS T2 ON T1.Manufacturer = T2.code WHERE T2.name = 'Creative Labs' INTERSECT SELECT T1.name FROM products AS T1 JOIN manufacturers AS T2 ON T1.Manufacturer = T2.code WHERE T2.name = 'Sony'
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE manufacturers (code VARCHAR, name VARCHAR); CREATE TABLE products (name VARCHAR, Manufacturer VARCHAR) Question: Find the name of product that is produced by both companies Creative Labs and Sony. [/INST] SELECT T1.name FROM products AS T1 JOIN manufacturers AS T2 ON T1.Manufacturer = T2.code WHERE T2.name = 'Creative Labs' INTERSECT SELECT T1.name FROM products AS T1 JOIN manufacturers AS T2 ON T1.Manufacturer = T2.code WHERE T2.name = 'Sony' </s>
Find the name, headquarter and founder of the manufacturer that has the highest revenue.
CREATE TABLE manufacturers (name VARCHAR, headquarter VARCHAR, founder VARCHAR, revenue VARCHAR)
SELECT TOP 1 name, headquarter, founder FROM manufacturers ORDER BY revenue DESC
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE manufacturers (name VARCHAR, headquarter VARCHAR, founder VARCHAR, revenue VARCHAR) Question: Find the name, headquarter and founder of the manufacturer that has the highest revenue. [/INST] SELECT TOP 1 name, headquarter, founder FROM manufacturers ORDER BY revenue DESC </s>
Find the name, headquarter and revenue of all manufacturers sorted by their revenue in the descending order.
CREATE TABLE manufacturers (name VARCHAR, headquarter VARCHAR, revenue VARCHAR)
SELECT name, headquarter, revenue FROM manufacturers ORDER BY revenue DESC
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE manufacturers (name VARCHAR, headquarter VARCHAR, revenue VARCHAR) Question: Find the name, headquarter and revenue of all manufacturers sorted by their revenue in the descending order. [/INST] SELECT name, headquarter, revenue FROM manufacturers ORDER BY revenue DESC </s>
Find the name of companies whose revenue is greater than the average revenue of all companies.
CREATE TABLE manufacturers (name VARCHAR, revenue INTEGER)
SELECT name FROM manufacturers WHERE revenue > (SELECT AVG(revenue) FROM manufacturers)
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE manufacturers (name VARCHAR, revenue INTEGER) Question: Find the name of companies whose revenue is greater than the average revenue of all companies. [/INST] SELECT name FROM manufacturers WHERE revenue > (SELECT AVG(revenue) FROM manufacturers) </s>
Find the name of companies whose revenue is smaller than the revenue of all companies based in Austin.
CREATE TABLE manufacturers (name VARCHAR, revenue INTEGER, headquarter VARCHAR)
SELECT name FROM manufacturers WHERE revenue < (SELECT MIN(revenue) FROM manufacturers WHERE headquarter = 'Austin')
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE manufacturers (name VARCHAR, revenue INTEGER, headquarter VARCHAR) Question: Find the name of companies whose revenue is smaller than the revenue of all companies based in Austin. [/INST] SELECT name FROM manufacturers WHERE revenue < (SELECT MIN(revenue) FROM manufacturers WHERE headquarter = 'Austin') </s>
Find the total revenue of companies whose revenue is larger than the revenue of some companies based in Austin.
CREATE TABLE manufacturers (revenue INTEGER, headquarter VARCHAR)
SELECT SUM(revenue) FROM manufacturers WHERE revenue > (SELECT MIN(revenue) FROM manufacturers WHERE headquarter = 'Austin')
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE manufacturers (revenue INTEGER, headquarter VARCHAR) Question: Find the total revenue of companies whose revenue is larger than the revenue of some companies based in Austin. [/INST] SELECT SUM(revenue) FROM manufacturers WHERE revenue > (SELECT MIN(revenue) FROM manufacturers WHERE headquarter = 'Austin') </s>
Find the total revenue of companies of each founder.
CREATE TABLE manufacturers (founder VARCHAR, revenue INTEGER)
SELECT SUM(revenue), founder FROM manufacturers GROUP BY founder
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE manufacturers (founder VARCHAR, revenue INTEGER) Question: Find the total revenue of companies of each founder. [/INST] SELECT SUM(revenue), founder FROM manufacturers GROUP BY founder </s>
Find the name and revenue of the company that earns the highest revenue in each city.
CREATE TABLE manufacturers (name VARCHAR, Headquarter VARCHAR, revenue INTEGER)
SELECT name, MAX(revenue), Headquarter FROM manufacturers GROUP BY Headquarter
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE manufacturers (name VARCHAR, Headquarter VARCHAR, revenue INTEGER) Question: Find the name and revenue of the company that earns the highest revenue in each city. [/INST] SELECT name, MAX(revenue), Headquarter FROM manufacturers GROUP BY Headquarter </s>
Find the total revenue for each manufacturer.
CREATE TABLE manufacturers (name VARCHAR, revenue INTEGER)
SELECT SUM(revenue), name FROM manufacturers GROUP BY name
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE manufacturers (name VARCHAR, revenue INTEGER) Question: Find the total revenue for each manufacturer. [/INST] SELECT SUM(revenue), name FROM manufacturers GROUP BY name </s>
Find the average prices of all products from each manufacture, and list each company's name.
CREATE TABLE products (price INTEGER, Manufacturer VARCHAR); CREATE TABLE manufacturers (name VARCHAR, code VARCHAR)
SELECT AVG(T1.price), T2.name FROM products AS T1 JOIN manufacturers AS T2 ON T1.Manufacturer = T2.code GROUP BY T2.name
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE products (price INTEGER, Manufacturer VARCHAR); CREATE TABLE manufacturers (name VARCHAR, code VARCHAR) Question: Find the average prices of all products from each manufacture, and list each company's name. [/INST] SELECT AVG(T1.price), T2.name FROM products AS T1 JOIN manufacturers AS T2 ON T1.Manufacturer = T2.code GROUP BY T2.name </s>
Find the number of different products that are produced by companies at different headquarter cities.
CREATE TABLE manufacturers (Headquarter VARCHAR, code VARCHAR); CREATE TABLE products (name VARCHAR, Manufacturer VARCHAR)
SELECT COUNT(DISTINCT T1.name), T2.Headquarter FROM products AS T1 JOIN manufacturers AS T2 ON T1.Manufacturer = T2.code GROUP BY T2.Headquarter
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE manufacturers (Headquarter VARCHAR, code VARCHAR); CREATE TABLE products (name VARCHAR, Manufacturer VARCHAR) Question: Find the number of different products that are produced by companies at different headquarter cities. [/INST] SELECT COUNT(DISTINCT T1.name), T2.Headquarter FROM products AS T1 JOIN manufacturers AS T2 ON T1.Manufacturer = T2.code GROUP BY T2.Headquarter </s>
Find number of products which Sony does not make.
CREATE TABLE manufacturers (code VARCHAR, name VARCHAR); CREATE TABLE products (name VARCHAR); CREATE TABLE products (name VARCHAR, Manufacturer VARCHAR)
SELECT COUNT(DISTINCT name) FROM products WHERE NOT name IN (SELECT T1.name FROM products AS T1 JOIN manufacturers AS T2 ON T1.Manufacturer = T2.code WHERE T2.name = 'Sony')
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE manufacturers (code VARCHAR, name VARCHAR); CREATE TABLE products (name VARCHAR); CREATE TABLE products (name VARCHAR, Manufacturer VARCHAR) Question: Find number of products which Sony does not make. [/INST] SELECT COUNT(DISTINCT name) FROM products WHERE NOT name IN (SELECT T1.name FROM products AS T1 JOIN manufacturers AS T2 ON T1.Manufacturer = T2.code WHERE T2.name = 'Sony') </s>
Find the name of companies that do not make DVD drive.
CREATE TABLE manufacturers (name VARCHAR, code VARCHAR); CREATE TABLE products (Manufacturer VARCHAR, name VARCHAR); CREATE TABLE manufacturers (name VARCHAR)
SELECT name FROM manufacturers EXCEPT SELECT T2.name FROM products AS T1 JOIN manufacturers AS T2 ON T1.Manufacturer = T2.code WHERE T1.name = 'DVD drive'
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE manufacturers (name VARCHAR, code VARCHAR); CREATE TABLE products (Manufacturer VARCHAR, name VARCHAR); CREATE TABLE manufacturers (name VARCHAR) Question: Find the name of companies that do not make DVD drive. [/INST] SELECT name FROM manufacturers EXCEPT SELECT T2.name FROM products AS T1 JOIN manufacturers AS T2 ON T1.Manufacturer = T2.code WHERE T1.name = 'DVD drive' </s>
Find the number of products for each manufacturer, showing the name of each company.
CREATE TABLE products (Manufacturer VARCHAR); CREATE TABLE manufacturers (name VARCHAR, code VARCHAR)
SELECT COUNT(*), T2.name FROM products AS T1 JOIN manufacturers AS T2 ON T1.Manufacturer = T2.code GROUP BY T2.name
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE products (Manufacturer VARCHAR); CREATE TABLE manufacturers (name VARCHAR, code VARCHAR) Question: Find the number of products for each manufacturer, showing the name of each company. [/INST] SELECT COUNT(*), T2.name FROM products AS T1 JOIN manufacturers AS T2 ON T1.Manufacturer = T2.code GROUP BY T2.name </s>
Select the names of all the products in the store.
CREATE TABLE Products (Name VARCHAR)
SELECT Name FROM Products
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Products (Name VARCHAR) Question: Select the names of all the products in the store. [/INST] SELECT Name FROM Products </s>
Select the names and the prices of all the products in the store.
CREATE TABLE products (name VARCHAR, price VARCHAR)
SELECT name, price FROM products
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE products (name VARCHAR, price VARCHAR) Question: Select the names and the prices of all the products in the store. [/INST] SELECT name, price FROM products </s>
Select the name of the products with a price less than or equal to $200.
CREATE TABLE products (name VARCHAR, price VARCHAR)
SELECT name FROM products WHERE price <= 200
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE products (name VARCHAR, price VARCHAR) Question: Select the name of the products with a price less than or equal to $200. [/INST] SELECT name FROM products WHERE price <= 200 </s>
Find all information of all the products with a price between $60 and $120.
CREATE TABLE products (price INTEGER)
SELECT * FROM products WHERE price BETWEEN 60 AND 120
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE products (price INTEGER) Question: Find all information of all the products with a price between $60 and $120. [/INST] SELECT * FROM products WHERE price BETWEEN 60 AND 120 </s>
Compute the average price of all the products.
CREATE TABLE products (price INTEGER)
SELECT AVG(price) FROM products
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE products (price INTEGER) Question: Compute the average price of all the products. [/INST] SELECT AVG(price) FROM products </s>
Compute the average price of all products with manufacturer code equal to 2.
CREATE TABLE products (price INTEGER, Manufacturer VARCHAR)
SELECT AVG(price) FROM products WHERE Manufacturer = 2
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE products (price INTEGER, Manufacturer VARCHAR) Question: Compute the average price of all products with manufacturer code equal to 2. [/INST] SELECT AVG(price) FROM products WHERE Manufacturer = 2 </s>
Compute the number of products with a price larger than or equal to $180.
CREATE TABLE products (price VARCHAR)
SELECT COUNT(*) FROM products WHERE price >= 180
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE products (price VARCHAR) Question: Compute the number of products with a price larger than or equal to $180. [/INST] SELECT COUNT(*) FROM products WHERE price >= 180 </s>
Select the name and price of all products with a price larger than or equal to $180, and sort first by price (in descending order), and then by name (in ascending order).
CREATE TABLE products (name VARCHAR, price VARCHAR)
SELECT name, price FROM products WHERE price >= 180 ORDER BY price DESC, name
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE products (name VARCHAR, price VARCHAR) Question: Select the name and price of all products with a price larger than or equal to $180, and sort first by price (in descending order), and then by name (in ascending order). [/INST] SELECT name, price FROM products WHERE price >= 180 ORDER BY price DESC, name </s>
Select all the data from the products and each product's manufacturer.
CREATE TABLE products (manufacturer VARCHAR); CREATE TABLE Manufacturers (code VARCHAR)
SELECT * FROM products AS T1 JOIN Manufacturers AS T2 ON T1.manufacturer = T2.code
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE products (manufacturer VARCHAR); CREATE TABLE Manufacturers (code VARCHAR) Question: Select all the data from the products and each product's manufacturer. [/INST] SELECT * FROM products AS T1 JOIN Manufacturers AS T2 ON T1.manufacturer = T2.code </s>
Select the average price of each manufacturer's products, showing only the manufacturer's code.
CREATE TABLE Products (Manufacturer VARCHAR, Price INTEGER)
SELECT AVG(Price), Manufacturer FROM Products GROUP BY Manufacturer
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Products (Manufacturer VARCHAR, Price INTEGER) Question: Select the average price of each manufacturer's products, showing only the manufacturer's code. [/INST] SELECT AVG(Price), Manufacturer FROM Products GROUP BY Manufacturer </s>
Select the average price of each manufacturer's products, showing the manufacturer's name.
CREATE TABLE Manufacturers (name VARCHAR, code VARCHAR); CREATE TABLE products (Price INTEGER, manufacturer VARCHAR)
SELECT AVG(T1.Price), T2.name FROM products AS T1 JOIN Manufacturers AS T2 ON T1.manufacturer = T2.code GROUP BY T2.name
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Manufacturers (name VARCHAR, code VARCHAR); CREATE TABLE products (Price INTEGER, manufacturer VARCHAR) Question: Select the average price of each manufacturer's products, showing the manufacturer's name. [/INST] SELECT AVG(T1.Price), T2.name FROM products AS T1 JOIN Manufacturers AS T2 ON T1.manufacturer = T2.code GROUP BY T2.name </s>
Select the names of manufacturer whose products have an average price higher than or equal to $150.
CREATE TABLE Manufacturers (name VARCHAR, code VARCHAR); CREATE TABLE products (Price INTEGER, manufacturer VARCHAR, price INTEGER)
SELECT AVG(T1.Price), T2.name FROM products AS T1 JOIN Manufacturers AS T2 ON T1.manufacturer = T2.code GROUP BY T2.name HAVING AVG(T1.price) >= 150
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Manufacturers (name VARCHAR, code VARCHAR); CREATE TABLE products (Price INTEGER, manufacturer VARCHAR, price INTEGER) Question: Select the names of manufacturer whose products have an average price higher than or equal to $150. [/INST] SELECT AVG(T1.Price), T2.name FROM products AS T1 JOIN Manufacturers AS T2 ON T1.manufacturer = T2.code GROUP BY T2.name HAVING AVG(T1.price) >= 150 </s>
Select the name and price of the cheapest product.
CREATE TABLE Products (name VARCHAR, price VARCHAR)
SELECT TOP 1 name, price FROM Products ORDER BY price
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Products (name VARCHAR, price VARCHAR) Question: Select the name and price of the cheapest product. [/INST] SELECT TOP 1 name, price FROM Products ORDER BY price </s>
Select the name of each manufacturer along with the name and price of its most expensive product.
CREATE TABLE Manufacturers (name VARCHAR, code VARCHAR); CREATE TABLE products (Name VARCHAR, Price INTEGER, manufacturer VARCHAR)
SELECT T1.Name, MAX(T1.Price), T2.name FROM products AS T1 JOIN Manufacturers AS T2 ON T1.manufacturer = T2.code GROUP BY T2.name
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Manufacturers (name VARCHAR, code VARCHAR); CREATE TABLE products (Name VARCHAR, Price INTEGER, manufacturer VARCHAR) Question: Select the name of each manufacturer along with the name and price of its most expensive product. [/INST] SELECT T1.Name, MAX(T1.Price), T2.name FROM products AS T1 JOIN Manufacturers AS T2 ON T1.manufacturer = T2.code GROUP BY T2.name </s>
Select the code of the product that is cheapest in each product category.
CREATE TABLE products (code VARCHAR, name VARCHAR, price INTEGER)
SELECT code, name, MIN(price) FROM products GROUP BY name
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE products (code VARCHAR, name VARCHAR, price INTEGER) Question: Select the code of the product that is cheapest in each product category. [/INST] SELECT code, name, MIN(price) FROM products GROUP BY name </s>
What is the id of the problem log that is created most recently?
CREATE TABLE problem_log (problem_log_id VARCHAR, log_entry_date VARCHAR)
SELECT TOP 1 problem_log_id FROM problem_log ORDER BY log_entry_date DESC
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE problem_log (problem_log_id VARCHAR, log_entry_date VARCHAR) Question: What is the id of the problem log that is created most recently? [/INST] SELECT TOP 1 problem_log_id FROM problem_log ORDER BY log_entry_date DESC </s>
What is the oldest log id and its corresponding problem id?
CREATE TABLE problem_log (problem_log_id VARCHAR, problem_id VARCHAR, log_entry_date VARCHAR)
SELECT TOP 1 problem_log_id, problem_id FROM problem_log ORDER BY log_entry_date
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE problem_log (problem_log_id VARCHAR, problem_id VARCHAR, log_entry_date VARCHAR) Question: What is the oldest log id and its corresponding problem id? [/INST] SELECT TOP 1 problem_log_id, problem_id FROM problem_log ORDER BY log_entry_date </s>
Find all the ids and dates of the logs for the problem whose id is 10.
CREATE TABLE problem_log (problem_log_id VARCHAR, log_entry_date VARCHAR, problem_id VARCHAR)
SELECT problem_log_id, log_entry_date FROM problem_log WHERE problem_id = 10
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE problem_log (problem_log_id VARCHAR, log_entry_date VARCHAR, problem_id VARCHAR) Question: Find all the ids and dates of the logs for the problem whose id is 10. [/INST] SELECT problem_log_id, log_entry_date FROM problem_log WHERE problem_id = 10 </s>
List all the log ids and their descriptions from the problem logs.
CREATE TABLE problem_log (problem_log_id VARCHAR, log_entry_description VARCHAR)
SELECT problem_log_id, log_entry_description FROM problem_log
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE problem_log (problem_log_id VARCHAR, log_entry_description VARCHAR) Question: List all the log ids and their descriptions from the problem logs. [/INST] SELECT problem_log_id, log_entry_description FROM problem_log </s>
List the first and last names of all distinct staff members who are assigned to the problem whose id is 1.
CREATE TABLE problem_log (assigned_to_staff_id VARCHAR, problem_id VARCHAR); CREATE TABLE staff (staff_id VARCHAR)
SELECT DISTINCT staff_first_name, staff_last_name FROM staff AS T1 JOIN problem_log AS T2 ON T1.staff_id = T2.assigned_to_staff_id WHERE T2.problem_id = 1
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE problem_log (assigned_to_staff_id VARCHAR, problem_id VARCHAR); CREATE TABLE staff (staff_id VARCHAR) Question: List the first and last names of all distinct staff members who are assigned to the problem whose id is 1. [/INST] SELECT DISTINCT staff_first_name, staff_last_name FROM staff AS T1 JOIN problem_log AS T2 ON T1.staff_id = T2.assigned_to_staff_id WHERE T2.problem_id = 1 </s>
List the problem id and log id which are assigned to the staff named Rylan Homenick.
CREATE TABLE problem_log (problem_id VARCHAR, problem_log_id VARCHAR, assigned_to_staff_id VARCHAR); CREATE TABLE staff (staff_id VARCHAR, staff_first_name VARCHAR, staff_last_name VARCHAR)
SELECT DISTINCT T2.problem_id, T2.problem_log_id FROM staff AS T1 JOIN problem_log AS T2 ON T1.staff_id = T2.assigned_to_staff_id WHERE T1.staff_first_name = "Rylan" AND T1.staff_last_name = "Homenick"
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE problem_log (problem_id VARCHAR, problem_log_id VARCHAR, assigned_to_staff_id VARCHAR); CREATE TABLE staff (staff_id VARCHAR, staff_first_name VARCHAR, staff_last_name VARCHAR) Question: List the problem id and log id which are assigned to the staff named Rylan Homenick. [/INST] SELECT DISTINCT T2.problem_id, T2.problem_log_id FROM staff AS T1 JOIN problem_log AS T2 ON T1.staff_id = T2.assigned_to_staff_id WHERE T1.staff_first_name = "Rylan" AND T1.staff_last_name = "Homenick" </s>
How many problems are there for product voluptatem?
CREATE TABLE problems (product_id VARCHAR); CREATE TABLE product (product_id VARCHAR, product_name VARCHAR)
SELECT COUNT(*) FROM product AS T1 JOIN problems AS T2 ON T1.product_id = T2.product_id WHERE T1.product_name = "voluptatem"
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE problems (product_id VARCHAR); CREATE TABLE product (product_id VARCHAR, product_name VARCHAR) Question: How many problems are there for product voluptatem? [/INST] SELECT COUNT(*) FROM product AS T1 JOIN problems AS T2 ON T1.product_id = T2.product_id WHERE T1.product_name = "voluptatem" </s>
How many problems does the product with the most problems have? List the number of the problems and product name.
CREATE TABLE problems (product_id VARCHAR); CREATE TABLE product (product_name VARCHAR, product_id VARCHAR)
SELECT TOP 1 COUNT(*), T1.product_name FROM product AS T1 JOIN problems AS T2 ON T1.product_id = T2.product_id GROUP BY T1.product_name ORDER BY COUNT(*) DESC
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE problems (product_id VARCHAR); CREATE TABLE product (product_name VARCHAR, product_id VARCHAR) Question: How many problems does the product with the most problems have? List the number of the problems and product name. [/INST] SELECT TOP 1 COUNT(*), T1.product_name FROM product AS T1 JOIN problems AS T2 ON T1.product_id = T2.product_id GROUP BY T1.product_name ORDER BY COUNT(*) DESC </s>
Give me a list of descriptions of the problems that are reported by the staff whose first name is Christop.
CREATE TABLE staff (staff_id VARCHAR, staff_first_name VARCHAR); CREATE TABLE problems (problem_description VARCHAR, reported_by_staff_id VARCHAR)
SELECT T1.problem_description FROM problems AS T1 JOIN staff AS T2 ON T1.reported_by_staff_id = T2.staff_id WHERE T2.staff_first_name = "Christop"
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE staff (staff_id VARCHAR, staff_first_name VARCHAR); CREATE TABLE problems (problem_description VARCHAR, reported_by_staff_id VARCHAR) Question: Give me a list of descriptions of the problems that are reported by the staff whose first name is Christop. [/INST] SELECT T1.problem_description FROM problems AS T1 JOIN staff AS T2 ON T1.reported_by_staff_id = T2.staff_id WHERE T2.staff_first_name = "Christop" </s>
Find the ids of the problems that are reported by the staff whose last name is Bosco.
CREATE TABLE problems (problem_id VARCHAR, reported_by_staff_id VARCHAR); CREATE TABLE staff (staff_id VARCHAR, staff_last_name VARCHAR)
SELECT T1.problem_id FROM problems AS T1 JOIN staff AS T2 ON T1.reported_by_staff_id = T2.staff_id WHERE T2.staff_last_name = "Bosco"
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE problems (problem_id VARCHAR, reported_by_staff_id VARCHAR); CREATE TABLE staff (staff_id VARCHAR, staff_last_name VARCHAR) Question: Find the ids of the problems that are reported by the staff whose last name is Bosco. [/INST] SELECT T1.problem_id FROM problems AS T1 JOIN staff AS T2 ON T1.reported_by_staff_id = T2.staff_id WHERE T2.staff_last_name = "Bosco" </s>
What are the ids of the problems which are reported after 1978-06-26?
CREATE TABLE problems (problem_id VARCHAR, date_problem_reported INTEGER)
SELECT problem_id FROM problems WHERE date_problem_reported > "1978-06-26"
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE problems (problem_id VARCHAR, date_problem_reported INTEGER) Question: What are the ids of the problems which are reported after 1978-06-26? [/INST] SELECT problem_id FROM problems WHERE date_problem_reported > "1978-06-26" </s>
What are the ids of the problems which are reported before 1978-06-26?
CREATE TABLE problems (problem_id VARCHAR, date_problem_reported INTEGER)
SELECT problem_id FROM problems WHERE date_problem_reported < "1978-06-26"
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE problems (problem_id VARCHAR, date_problem_reported INTEGER) Question: What are the ids of the problems which are reported before 1978-06-26? [/INST] SELECT problem_id FROM problems WHERE date_problem_reported < "1978-06-26" </s>
For each product which has problems, what are the number of problems and the product id?
CREATE TABLE problems (product_id VARCHAR); CREATE TABLE product (product_id VARCHAR)
SELECT COUNT(*), T2.product_id FROM problems AS T1 JOIN product AS T2 ON T1.product_id = T2.product_id GROUP BY T2.product_id
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE problems (product_id VARCHAR); CREATE TABLE product (product_id VARCHAR) Question: For each product which has problems, what are the number of problems and the product id? [/INST] SELECT COUNT(*), T2.product_id FROM problems AS T1 JOIN product AS T2 ON T1.product_id = T2.product_id GROUP BY T2.product_id </s>
For each product that has problems, find the number of problems reported after 1986-11-13 and the product id?
CREATE TABLE product (product_id VARCHAR); CREATE TABLE problems (product_id VARCHAR, date_problem_reported INTEGER)
SELECT COUNT(*), T2.product_id FROM problems AS T1 JOIN product AS T2 ON T1.product_id = T2.product_id WHERE T1.date_problem_reported > "1986-11-13" GROUP BY T2.product_id
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE product (product_id VARCHAR); CREATE TABLE problems (product_id VARCHAR, date_problem_reported INTEGER) Question: For each product that has problems, find the number of problems reported after 1986-11-13 and the product id? [/INST] SELECT COUNT(*), T2.product_id FROM problems AS T1 JOIN product AS T2 ON T1.product_id = T2.product_id WHERE T1.date_problem_reported > "1986-11-13" GROUP BY T2.product_id </s>
List the names of all the distinct product names in alphabetical order?
CREATE TABLE product (product_name VARCHAR)
SELECT DISTINCT product_name FROM product ORDER BY product_name
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE product (product_name VARCHAR) Question: List the names of all the distinct product names in alphabetical order? [/INST] SELECT DISTINCT product_name FROM product ORDER BY product_name </s>
List all the distinct product names ordered by product id?
CREATE TABLE product (product_name VARCHAR, product_id VARCHAR)
SELECT DISTINCT product_name FROM product ORDER BY product_id
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE product (product_name VARCHAR, product_id VARCHAR) Question: List all the distinct product names ordered by product id? [/INST] SELECT DISTINCT product_name FROM product ORDER BY product_id </s>
What are the id of problems reported by the staff named Dameon Frami or Jolie Weber?
CREATE TABLE staff (staff_id VARCHAR, staff_first_name VARCHAR, staff_last_name VARCHAR); CREATE TABLE problems (reported_by_staff_id VARCHAR)
SELECT product_id FROM problems AS T1 JOIN staff AS T2 ON T1.reported_by_staff_id = T2.staff_id WHERE T2.staff_first_name = "Dameon" AND T2.staff_last_name = "Frami" UNION SELECT product_id FROM problems AS T1 JOIN staff AS T2 ON T1.reported_by_staff_id = T2.staff_id WHERE T2.staff_first_name = "Jolie" AND T2.staff_last_name = "Weber"
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE staff (staff_id VARCHAR, staff_first_name VARCHAR, staff_last_name VARCHAR); CREATE TABLE problems (reported_by_staff_id VARCHAR) Question: What are the id of problems reported by the staff named Dameon Frami or Jolie Weber? [/INST] SELECT product_id FROM problems AS T1 JOIN staff AS T2 ON T1.reported_by_staff_id = T2.staff_id WHERE T2.staff_first_name = "Dameon" AND T2.staff_last_name = "Frami" UNION SELECT product_id FROM problems AS T1 JOIN staff AS T2 ON T1.reported_by_staff_id = T2.staff_id WHERE T2.staff_first_name = "Jolie" AND T2.staff_last_name = "Weber" </s>
What are the product ids for the problems reported by Christop Berge with closure authorised by Ashley Medhurst?
CREATE TABLE problems (reported_by_staff_id VARCHAR, closure_authorised_by_staff_id VARCHAR); CREATE TABLE staff (staff_id VARCHAR, staff_first_name VARCHAR, staff_last_name VARCHAR)
SELECT product_id FROM problems AS T1 JOIN staff AS T2 ON T1.reported_by_staff_id = T2.staff_id WHERE T2.staff_first_name = "Christop" AND T2.staff_last_name = "Berge" INTERSECT SELECT product_id FROM problems AS T1 JOIN staff AS T2 ON T1.closure_authorised_by_staff_id = T2.staff_id WHERE T2.staff_first_name = "Ashley" AND T2.staff_last_name = "Medhurst"
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE problems (reported_by_staff_id VARCHAR, closure_authorised_by_staff_id VARCHAR); CREATE TABLE staff (staff_id VARCHAR, staff_first_name VARCHAR, staff_last_name VARCHAR) Question: What are the product ids for the problems reported by Christop Berge with closure authorised by Ashley Medhurst? [/INST] SELECT product_id FROM problems AS T1 JOIN staff AS T2 ON T1.reported_by_staff_id = T2.staff_id WHERE T2.staff_first_name = "Christop" AND T2.staff_last_name = "Berge" INTERSECT SELECT product_id FROM problems AS T1 JOIN staff AS T2 ON T1.closure_authorised_by_staff_id = T2.staff_id WHERE T2.staff_first_name = "Ashley" AND T2.staff_last_name = "Medhurst" </s>
What are the ids of the problems reported before the date of any problem reported by Lysanne Turcotte?
CREATE TABLE problems (problem_id VARCHAR, reported_by_staff_id VARCHAR); CREATE TABLE staff (staff_id VARCHAR, staff_first_name VARCHAR, staff_last_name VARCHAR); CREATE TABLE problems (reported_by_staff_id VARCHAR); CREATE TABLE staff (staff_id VARCHAR)
SELECT T1.problem_id FROM problems AS T1 JOIN staff AS T2 ON T1.reported_by_staff_id = T2.staff_id WHERE date_problem_reported < (SELECT MIN(date_problem_reported) FROM problems AS T3 JOIN staff AS T4 ON T3.reported_by_staff_id = T4.staff_id WHERE T4.staff_first_name = "Lysanne" AND T4.staff_last_name = "Turcotte")
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE problems (problem_id VARCHAR, reported_by_staff_id VARCHAR); CREATE TABLE staff (staff_id VARCHAR, staff_first_name VARCHAR, staff_last_name VARCHAR); CREATE TABLE problems (reported_by_staff_id VARCHAR); CREATE TABLE staff (staff_id VARCHAR) Question: What are the ids of the problems reported before the date of any problem reported by Lysanne Turcotte? [/INST] SELECT T1.problem_id FROM problems AS T1 JOIN staff AS T2 ON T1.reported_by_staff_id = T2.staff_id WHERE date_problem_reported < (SELECT MIN(date_problem_reported) FROM problems AS T3 JOIN staff AS T4 ON T3.reported_by_staff_id = T4.staff_id WHERE T4.staff_first_name = "Lysanne" AND T4.staff_last_name = "Turcotte") </s>
What are the ids of the problems reported after the date of any problems reported by Rylan Homenick?
CREATE TABLE problems (problem_id VARCHAR, reported_by_staff_id VARCHAR); CREATE TABLE staff (staff_id VARCHAR, staff_first_name VARCHAR, staff_last_name VARCHAR); CREATE TABLE problems (reported_by_staff_id VARCHAR); CREATE TABLE staff (staff_id VARCHAR)
SELECT T1.problem_id FROM problems AS T1 JOIN staff AS T2 ON T1.reported_by_staff_id = T2.staff_id WHERE date_problem_reported > (SELECT MAX(date_problem_reported) FROM problems AS T3 JOIN staff AS T4 ON T3.reported_by_staff_id = T4.staff_id WHERE T4.staff_first_name = "Rylan" AND T4.staff_last_name = "Homenick")
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE problems (problem_id VARCHAR, reported_by_staff_id VARCHAR); CREATE TABLE staff (staff_id VARCHAR, staff_first_name VARCHAR, staff_last_name VARCHAR); CREATE TABLE problems (reported_by_staff_id VARCHAR); CREATE TABLE staff (staff_id VARCHAR) Question: What are the ids of the problems reported after the date of any problems reported by Rylan Homenick? [/INST] SELECT T1.problem_id FROM problems AS T1 JOIN staff AS T2 ON T1.reported_by_staff_id = T2.staff_id WHERE date_problem_reported > (SELECT MAX(date_problem_reported) FROM problems AS T3 JOIN staff AS T4 ON T3.reported_by_staff_id = T4.staff_id WHERE T4.staff_first_name = "Rylan" AND T4.staff_last_name = "Homenick") </s>
Find the top 3 products which have the largest number of problems?
CREATE TABLE problems (product_id VARCHAR); CREATE TABLE product (product_name VARCHAR, product_id VARCHAR)
SELECT TOP 3 T2.product_name FROM problems AS T1 JOIN product AS T2 ON T1.product_id = T2.product_id GROUP BY T2.product_name ORDER BY COUNT(*) DESC
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE problems (product_id VARCHAR); CREATE TABLE product (product_name VARCHAR, product_id VARCHAR) Question: Find the top 3 products which have the largest number of problems? [/INST] SELECT TOP 3 T2.product_name FROM problems AS T1 JOIN product AS T2 ON T1.product_id = T2.product_id GROUP BY T2.product_name ORDER BY COUNT(*) DESC </s>
List the ids of the problems from the product "voluptatem" that are reported after 1995?
CREATE TABLE problems (problem_id VARCHAR, product_id VARCHAR, date_problem_reported VARCHAR); CREATE TABLE product (product_id VARCHAR, product_name VARCHAR)
SELECT T1.problem_id FROM problems AS T1 JOIN product AS T2 ON T1.product_id = T2.product_id WHERE T2.product_name = "voluptatem" AND T1.date_problem_reported > "1995"
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE problems (problem_id VARCHAR, product_id VARCHAR, date_problem_reported VARCHAR); CREATE TABLE product (product_id VARCHAR, product_name VARCHAR) Question: List the ids of the problems from the product "voluptatem" that are reported after 1995? [/INST] SELECT T1.problem_id FROM problems AS T1 JOIN product AS T2 ON T1.product_id = T2.product_id WHERE T2.product_name = "voluptatem" AND T1.date_problem_reported > "1995" </s>
Find the first and last name of the staff members who reported problems from the product "rem" but not "aut"?
CREATE TABLE product (product_name VARCHAR, product_id VARCHAR); CREATE TABLE staff (staff_first_name VARCHAR, staff_last_name VARCHAR, staff_id VARCHAR); CREATE TABLE problems (product_id VARCHAR, reported_by_staff_id VARCHAR)
SELECT T3.staff_first_name, T3.staff_last_name FROM problems AS T1, product AS T2 JOIN staff AS T3 ON T1.product_id = T2.product_id AND T1.reported_by_staff_id = T3.staff_id WHERE T2.product_name = "rem" EXCEPT SELECT T3.staff_first_name, T3.staff_last_name FROM problems AS T1, product AS T2 JOIN staff AS T3 ON T1.product_id = T2.product_id AND T1.reported_by_staff_id = T3.staff_id WHERE T2.product_name = "aut"
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE product (product_name VARCHAR, product_id VARCHAR); CREATE TABLE staff (staff_first_name VARCHAR, staff_last_name VARCHAR, staff_id VARCHAR); CREATE TABLE problems (product_id VARCHAR, reported_by_staff_id VARCHAR) Question: Find the first and last name of the staff members who reported problems from the product "rem" but not "aut"? [/INST] SELECT T3.staff_first_name, T3.staff_last_name FROM problems AS T1, product AS T2 JOIN staff AS T3 ON T1.product_id = T2.product_id AND T1.reported_by_staff_id = T3.staff_id WHERE T2.product_name = "rem" EXCEPT SELECT T3.staff_first_name, T3.staff_last_name FROM problems AS T1, product AS T2 JOIN staff AS T3 ON T1.product_id = T2.product_id AND T1.reported_by_staff_id = T3.staff_id WHERE T2.product_name = "aut" </s>
Find the products which have problems reported by both Lacey Bosco and Kenton Champlin?
CREATE TABLE product (product_name VARCHAR, product_id VARCHAR); CREATE TABLE staff (staff_id VARCHAR, staff_first_name VARCHAR, staff_last_name VARCHAR); CREATE TABLE problems (product_id VARCHAR, reported_by_staff_id VARCHAR)
SELECT T2.product_name FROM problems AS T1, product AS T2 JOIN staff AS T3 ON T1.product_id = T2.product_id AND T1.reported_by_staff_id = T3.staff_id WHERE T3.staff_first_name = "Lacey" AND T3.staff_last_name = "Bosco" INTERSECT SELECT T2.product_name FROM problems AS T1, product AS T2 JOIN staff AS T3 ON T1.product_id = T2.product_id AND T1.reported_by_staff_id = T3.staff_id WHERE T3.staff_first_name = "Kenton" AND T3.staff_last_name = "Champlin"
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE product (product_name VARCHAR, product_id VARCHAR); CREATE TABLE staff (staff_id VARCHAR, staff_first_name VARCHAR, staff_last_name VARCHAR); CREATE TABLE problems (product_id VARCHAR, reported_by_staff_id VARCHAR) Question: Find the products which have problems reported by both Lacey Bosco and Kenton Champlin? [/INST] SELECT T2.product_name FROM problems AS T1, product AS T2 JOIN staff AS T3 ON T1.product_id = T2.product_id AND T1.reported_by_staff_id = T3.staff_id WHERE T3.staff_first_name = "Lacey" AND T3.staff_last_name = "Bosco" INTERSECT SELECT T2.product_name FROM problems AS T1, product AS T2 JOIN staff AS T3 ON T1.product_id = T2.product_id AND T1.reported_by_staff_id = T3.staff_id WHERE T3.staff_first_name = "Kenton" AND T3.staff_last_name = "Champlin" </s>
How many branches where have more than average number of memberships are there?
CREATE TABLE branch (membership_amount INTEGER)
SELECT COUNT(*) FROM branch WHERE membership_amount > (SELECT AVG(membership_amount) FROM branch)
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE branch (membership_amount INTEGER) Question: How many branches where have more than average number of memberships are there? [/INST] SELECT COUNT(*) FROM branch WHERE membership_amount > (SELECT AVG(membership_amount) FROM branch) </s>
Show name, address road, and city for all branches sorted by open year.
CREATE TABLE branch (name VARCHAR, address_road VARCHAR, city VARCHAR, open_year VARCHAR)
SELECT name, address_road, city FROM branch ORDER BY open_year
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE branch (name VARCHAR, address_road VARCHAR, city VARCHAR, open_year VARCHAR) Question: Show name, address road, and city for all branches sorted by open year. [/INST] SELECT name, address_road, city FROM branch ORDER BY open_year </s>
What are names for top three branches with most number of membership?
CREATE TABLE branch (name VARCHAR, membership_amount VARCHAR)
SELECT TOP 3 name FROM branch ORDER BY membership_amount DESC
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE branch (name VARCHAR, membership_amount VARCHAR) Question: What are names for top three branches with most number of membership? [/INST] SELECT TOP 3 name FROM branch ORDER BY membership_amount DESC </s>
Show all distinct city where branches with at least 100 memberships are located.
CREATE TABLE branch (city VARCHAR, membership_amount VARCHAR)
SELECT DISTINCT city FROM branch WHERE membership_amount >= 100
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE branch (city VARCHAR, membership_amount VARCHAR) Question: Show all distinct city where branches with at least 100 memberships are located. [/INST] SELECT DISTINCT city FROM branch WHERE membership_amount >= 100 </s>
List all open years when at least two shops are opened.
CREATE TABLE branch (open_year VARCHAR)
SELECT open_year FROM branch GROUP BY open_year HAVING COUNT(*) >= 2
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE branch (open_year VARCHAR) Question: List all open years when at least two shops are opened. [/INST] SELECT open_year FROM branch GROUP BY open_year HAVING COUNT(*) >= 2 </s>
Show minimum and maximum amount of memberships for all branches opened in 2011 or located at city London.
CREATE TABLE branch (membership_amount INTEGER, open_year VARCHAR, city VARCHAR)
SELECT MIN(membership_amount), MAX(membership_amount) FROM branch WHERE open_year = 2011 OR city = 'London'
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE branch (membership_amount INTEGER, open_year VARCHAR, city VARCHAR) Question: Show minimum and maximum amount of memberships for all branches opened in 2011 or located at city London. [/INST] SELECT MIN(membership_amount), MAX(membership_amount) FROM branch WHERE open_year = 2011 OR city = 'London' </s>
Show the city and the number of branches opened before 2010 for each city.
CREATE TABLE branch (city VARCHAR, open_year INTEGER)
SELECT city, COUNT(*) FROM branch WHERE open_year < 2010 GROUP BY city
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE branch (city VARCHAR, open_year INTEGER) Question: Show the city and the number of branches opened before 2010 for each city. [/INST] SELECT city, COUNT(*) FROM branch WHERE open_year < 2010 GROUP BY city </s>
How many different levels do members have?
CREATE TABLE member (LEVEL VARCHAR)
SELECT COUNT(DISTINCT LEVEL) FROM member
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE member (LEVEL VARCHAR) Question: How many different levels do members have? [/INST] SELECT COUNT(DISTINCT LEVEL) FROM member </s>
Show card number, name, and hometown for all members in a descending order of level.
CREATE TABLE member (card_number VARCHAR, name VARCHAR, hometown VARCHAR, LEVEL VARCHAR)
SELECT card_number, name, hometown FROM member ORDER BY LEVEL DESC
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE member (card_number VARCHAR, name VARCHAR, hometown VARCHAR, LEVEL VARCHAR) Question: Show card number, name, and hometown for all members in a descending order of level. [/INST] SELECT card_number, name, hometown FROM member ORDER BY LEVEL DESC </s>
Show the membership level with most number of members.
CREATE TABLE member (LEVEL VARCHAR)
SELECT TOP 1 LEVEL FROM member GROUP BY LEVEL ORDER BY COUNT(*) DESC
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE member (LEVEL VARCHAR) Question: Show the membership level with most number of members. [/INST] SELECT TOP 1 LEVEL FROM member GROUP BY LEVEL ORDER BY COUNT(*) DESC </s>
Show all member names and registered branch names sorted by register year.
CREATE TABLE member (name VARCHAR, member_id VARCHAR); CREATE TABLE membership_register_branch (branch_id VARCHAR, member_id VARCHAR, register_year VARCHAR); CREATE TABLE branch (name VARCHAR, branch_id VARCHAR)
SELECT T3.name, T2.name FROM membership_register_branch AS T1 JOIN branch AS T2 ON T1.branch_id = T2.branch_id JOIN member AS T3 ON T1.member_id = T3.member_id ORDER BY T1.register_year
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE member (name VARCHAR, member_id VARCHAR); CREATE TABLE membership_register_branch (branch_id VARCHAR, member_id VARCHAR, register_year VARCHAR); CREATE TABLE branch (name VARCHAR, branch_id VARCHAR) Question: Show all member names and registered branch names sorted by register year. [/INST] SELECT T3.name, T2.name FROM membership_register_branch AS T1 JOIN branch AS T2 ON T1.branch_id = T2.branch_id JOIN member AS T3 ON T1.member_id = T3.member_id ORDER BY T1.register_year </s>
Show all branch names with the number of members in each branch registered after 2015.
CREATE TABLE branch (name VARCHAR, branch_id VARCHAR); CREATE TABLE membership_register_branch (branch_id VARCHAR, register_year INTEGER)
SELECT T2.name, COUNT(*) FROM membership_register_branch AS T1 JOIN branch AS T2 ON T1.branch_id = T2.branch_id WHERE T1.register_year > 2015 GROUP BY T2.branch_id
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE branch (name VARCHAR, branch_id VARCHAR); CREATE TABLE membership_register_branch (branch_id VARCHAR, register_year INTEGER) Question: Show all branch names with the number of members in each branch registered after 2015. [/INST] SELECT T2.name, COUNT(*) FROM membership_register_branch AS T1 JOIN branch AS T2 ON T1.branch_id = T2.branch_id WHERE T1.register_year > 2015 GROUP BY T2.branch_id </s>
Show member names without any registered branch.
CREATE TABLE member (name VARCHAR, member_id VARCHAR); CREATE TABLE membership_register_branch (name VARCHAR, member_id VARCHAR)
SELECT name FROM member WHERE NOT member_id IN (SELECT member_id FROM membership_register_branch)
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE member (name VARCHAR, member_id VARCHAR); CREATE TABLE membership_register_branch (name VARCHAR, member_id VARCHAR) Question: Show member names without any registered branch. [/INST] SELECT name FROM member WHERE NOT member_id IN (SELECT member_id FROM membership_register_branch) </s>
List the branch name and city without any registered members.
CREATE TABLE membership_register_branch (name VARCHAR, city VARCHAR, branch_id VARCHAR); CREATE TABLE branch (name VARCHAR, city VARCHAR, branch_id VARCHAR)
SELECT name, city FROM branch WHERE NOT branch_id IN (SELECT branch_id FROM membership_register_branch)
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE membership_register_branch (name VARCHAR, city VARCHAR, branch_id VARCHAR); CREATE TABLE branch (name VARCHAR, city VARCHAR, branch_id VARCHAR) Question: List the branch name and city without any registered members. [/INST] SELECT name, city FROM branch WHERE NOT branch_id IN (SELECT branch_id FROM membership_register_branch) </s>
What is the name and open year for the branch with most number of memberships registered in 2016?
CREATE TABLE membership_register_branch (branch_id VARCHAR, register_year VARCHAR); CREATE TABLE branch (name VARCHAR, open_year VARCHAR, branch_id VARCHAR)
SELECT TOP 1 T2.name, T2.open_year FROM membership_register_branch AS T1 JOIN branch AS T2 ON T1.branch_id = T2.branch_id WHERE T1.register_year = 2016 GROUP BY T2.branch_id ORDER BY COUNT(*) DESC
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE membership_register_branch (branch_id VARCHAR, register_year VARCHAR); CREATE TABLE branch (name VARCHAR, open_year VARCHAR, branch_id VARCHAR) Question: What is the name and open year for the branch with most number of memberships registered in 2016? [/INST] SELECT TOP 1 T2.name, T2.open_year FROM membership_register_branch AS T1 JOIN branch AS T2 ON T1.branch_id = T2.branch_id WHERE T1.register_year = 2016 GROUP BY T2.branch_id ORDER BY COUNT(*) DESC </s>
Show the member name and hometown who registered a branch in 2016.
CREATE TABLE member (name VARCHAR, hometown VARCHAR, member_id VARCHAR); CREATE TABLE membership_register_branch (member_id VARCHAR, register_year VARCHAR)
SELECT T2.name, T2.hometown FROM membership_register_branch AS T1 JOIN member AS T2 ON T1.member_id = T2.member_id WHERE T1.register_year = 2016
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE member (name VARCHAR, hometown VARCHAR, member_id VARCHAR); CREATE TABLE membership_register_branch (member_id VARCHAR, register_year VARCHAR) Question: Show the member name and hometown who registered a branch in 2016. [/INST] SELECT T2.name, T2.hometown FROM membership_register_branch AS T1 JOIN member AS T2 ON T1.member_id = T2.member_id WHERE T1.register_year = 2016 </s>
Show all city with a branch opened in 2001 and a branch with more than 100 membership.
CREATE TABLE branch (city VARCHAR, open_year VARCHAR, membership_amount VARCHAR)
SELECT city FROM branch WHERE open_year = 2001 AND membership_amount > 100
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE branch (city VARCHAR, open_year VARCHAR, membership_amount VARCHAR) Question: Show all city with a branch opened in 2001 and a branch with more than 100 membership. [/INST] SELECT city FROM branch WHERE open_year = 2001 AND membership_amount > 100 </s>
Show all cities without a branch having more than 100 memberships.
CREATE TABLE branch (city VARCHAR, membership_amount INTEGER)
SELECT city FROM branch EXCEPT SELECT city FROM branch WHERE membership_amount > 100
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE branch (city VARCHAR, membership_amount INTEGER) Question: Show all cities without a branch having more than 100 memberships. [/INST] SELECT city FROM branch EXCEPT SELECT city FROM branch WHERE membership_amount > 100 </s>
What is the sum of total pounds of purchase in year 2018 for all branches in London?
CREATE TABLE purchase (branch_id VARCHAR, year VARCHAR); CREATE TABLE branch (branch_id VARCHAR, city VARCHAR)
SELECT SUM(total_pounds) FROM purchase AS T1 JOIN branch AS T2 ON T1.branch_id = T2.branch_id WHERE T2.city = 'London' AND T1.year = 2018
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE purchase (branch_id VARCHAR, year VARCHAR); CREATE TABLE branch (branch_id VARCHAR, city VARCHAR) Question: What is the sum of total pounds of purchase in year 2018 for all branches in London? [/INST] SELECT SUM(total_pounds) FROM purchase AS T1 JOIN branch AS T2 ON T1.branch_id = T2.branch_id WHERE T2.city = 'London' AND T1.year = 2018 </s>
What is the total number of purchases for members with level 6?
CREATE TABLE member (member_id VARCHAR, level VARCHAR); CREATE TABLE purchase (member_id VARCHAR)
SELECT COUNT(*) FROM purchase AS T1 JOIN member AS T2 ON T1.member_id = T2.member_id WHERE T2.level = 6
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE member (member_id VARCHAR, level VARCHAR); CREATE TABLE purchase (member_id VARCHAR) Question: What is the total number of purchases for members with level 6? [/INST] SELECT COUNT(*) FROM purchase AS T1 JOIN member AS T2 ON T1.member_id = T2.member_id WHERE T2.level = 6 </s>
Find the name of branches where have some members whose hometown is in Louisville, Kentucky and some in Hiram, Georgia.
CREATE TABLE member (member_id VARCHAR, Hometown VARCHAR); CREATE TABLE branch (name VARCHAR, branch_id VARCHAR); CREATE TABLE membership_register_branch (branch_id VARCHAR, member_id VARCHAR)
SELECT T2.name FROM membership_register_branch AS T1 JOIN branch AS T2 ON T1.branch_id = T2.branch_id JOIN member AS T3 ON T1.member_id = T3.member_id WHERE T3.Hometown = 'Louisville , Kentucky' INTERSECT SELECT T2.name FROM membership_register_branch AS T1 JOIN branch AS T2 ON T1.branch_id = T2.branch_id JOIN member AS T3 ON T1.member_id = T3.member_id WHERE T3.Hometown = 'Hiram , Georgia'
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE member (member_id VARCHAR, Hometown VARCHAR); CREATE TABLE branch (name VARCHAR, branch_id VARCHAR); CREATE TABLE membership_register_branch (branch_id VARCHAR, member_id VARCHAR) Question: Find the name of branches where have some members whose hometown is in Louisville, Kentucky and some in Hiram, Georgia. [/INST] SELECT T2.name FROM membership_register_branch AS T1 JOIN branch AS T2 ON T1.branch_id = T2.branch_id JOIN member AS T3 ON T1.member_id = T3.member_id WHERE T3.Hometown = 'Louisville , Kentucky' INTERSECT SELECT T2.name FROM membership_register_branch AS T1 JOIN branch AS T2 ON T1.branch_id = T2.branch_id JOIN member AS T3 ON T1.member_id = T3.member_id WHERE T3.Hometown = 'Hiram , Georgia' </s>
list the card number of all members whose hometown address includes word "Kentucky".
CREATE TABLE member (card_number VARCHAR, Hometown VARCHAR)
SELECT card_number FROM member WHERE Hometown LIKE "%Kentucky%"
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE member (card_number VARCHAR, Hometown VARCHAR) Question: list the card number of all members whose hometown address includes word "Kentucky". [/INST] SELECT card_number FROM member WHERE Hometown LIKE "%Kentucky%" </s>
Find the number of students in total.
CREATE TABLE STUDENT (Id VARCHAR)
SELECT COUNT(*) FROM STUDENT
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE STUDENT (Id VARCHAR) Question: Find the number of students in total. [/INST] SELECT COUNT(*) FROM STUDENT </s>
Find the number of voting records in total.
CREATE TABLE VOTING_RECORD (Id VARCHAR)
SELECT COUNT(*) FROM VOTING_RECORD
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE VOTING_RECORD (Id VARCHAR) Question: Find the number of voting records in total. [/INST] SELECT COUNT(*) FROM VOTING_RECORD </s>
Find the distinct number of president votes.
CREATE TABLE VOTING_RECORD (President_Vote VARCHAR)
SELECT COUNT(DISTINCT President_Vote) FROM VOTING_RECORD
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE VOTING_RECORD (President_Vote VARCHAR) Question: Find the distinct number of president votes. [/INST] SELECT COUNT(DISTINCT President_Vote) FROM VOTING_RECORD </s>
Find the maximum age of all the students.
CREATE TABLE STUDENT (Age INTEGER)
SELECT MAX(Age) FROM STUDENT
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE STUDENT (Age INTEGER) Question: Find the maximum age of all the students. [/INST] SELECT MAX(Age) FROM STUDENT </s>
Find the last names of students with major 50.
CREATE TABLE STUDENT (LName VARCHAR, Major VARCHAR)
SELECT LName FROM STUDENT WHERE Major = 50
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE STUDENT (LName VARCHAR, Major VARCHAR) Question: Find the last names of students with major 50. [/INST] SELECT LName FROM STUDENT WHERE Major = 50 </s>
Find the first names of students with age above 22.
CREATE TABLE STUDENT (Fname VARCHAR, Age INTEGER)
SELECT Fname FROM STUDENT WHERE Age > 22
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE STUDENT (Fname VARCHAR, Age INTEGER) Question: Find the first names of students with age above 22. [/INST] SELECT Fname FROM STUDENT WHERE Age > 22 </s>
What are the majors of male (sex is M) students?
CREATE TABLE STUDENT (Major VARCHAR, Sex VARCHAR)
SELECT Major FROM STUDENT WHERE Sex = "M"
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE STUDENT (Major VARCHAR, Sex VARCHAR) Question: What are the majors of male (sex is M) students? [/INST] SELECT Major FROM STUDENT WHERE Sex = "M" </s>
What is the average age of female (sex is F) students?
CREATE TABLE STUDENT (Age INTEGER, Sex VARCHAR)
SELECT AVG(Age) FROM STUDENT WHERE Sex = "F"
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE STUDENT (Age INTEGER, Sex VARCHAR) Question: What is the average age of female (sex is F) students? [/INST] SELECT AVG(Age) FROM STUDENT WHERE Sex = "F" </s>