instruction
stringlengths
12
244
input
stringlengths
27
489
output
stringlengths
18
557
text
stringlengths
194
1.14k
Sort employee names by their age in ascending order.
CREATE TABLE employee (name VARCHAR, age VARCHAR)
SELECT name FROM employee ORDER BY age
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE employee (name VARCHAR, age VARCHAR) Question: Sort employee names by their age in ascending order. [/INST] SELECT name FROM employee ORDER BY age </s>
What is the number of employees from each city?
CREATE TABLE employee (city VARCHAR)
SELECT COUNT(*), city FROM employee GROUP BY city
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE employee (city VARCHAR) Question: What is the number of employees from each city? [/INST] SELECT COUNT(*), city FROM employee GROUP BY city </s>
Which cities do more than one employee under age 30 come from?
CREATE TABLE employee (city VARCHAR, age INTEGER)
SELECT city FROM employee WHERE age < 30 GROUP BY city HAVING COUNT(*) > 1
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE employee (city VARCHAR, age INTEGER) Question: Which cities do more than one employee under age 30 come from? [/INST] SELECT city FROM employee WHERE age < 30 GROUP BY city HAVING COUNT(*) > 1 </s>
Find the number of shops in each location.
CREATE TABLE shop (LOCATION VARCHAR)
SELECT COUNT(*), LOCATION FROM shop GROUP BY LOCATION
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE shop (LOCATION VARCHAR) Question: Find the number of shops in each location. [/INST] SELECT COUNT(*), LOCATION FROM shop GROUP BY LOCATION </s>
Find the manager name and district of the shop whose number of products is the largest.
CREATE TABLE shop (manager_name VARCHAR, district VARCHAR, number_products VARCHAR)
SELECT TOP 1 manager_name, district FROM shop ORDER BY number_products DESC
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE shop (manager_name VARCHAR, district VARCHAR, number_products VARCHAR) Question: Find the manager name and district of the shop whose number of products is the largest. [/INST] SELECT TOP 1 manager_name, district FROM shop ORDER BY number_products DESC </s>
find the minimum and maximum number of products of all stores.
CREATE TABLE shop (Number_products INTEGER)
SELECT MIN(Number_products), MAX(Number_products) FROM shop
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE shop (Number_products INTEGER) Question: find the minimum and maximum number of products of all stores. [/INST] SELECT MIN(Number_products), MAX(Number_products) FROM shop </s>
Return the name, location and district of all shops in descending order of number of products.
CREATE TABLE shop (name VARCHAR, LOCATION VARCHAR, district VARCHAR, number_products VARCHAR)
SELECT name, LOCATION, district FROM shop ORDER BY number_products DESC
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE shop (name VARCHAR, LOCATION VARCHAR, district VARCHAR, number_products VARCHAR) Question: Return the name, location and district of all shops in descending order of number of products. [/INST] SELECT name, LOCATION, district FROM shop ORDER BY number_products DESC </s>
Find the names of stores whose number products is more than the average number of products.
CREATE TABLE shop (name VARCHAR, number_products INTEGER)
SELECT name FROM shop WHERE number_products > (SELECT AVG(number_products) FROM shop)
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE shop (name VARCHAR, number_products INTEGER) Question: Find the names of stores whose number products is more than the average number of products. [/INST] SELECT name FROM shop WHERE number_products > (SELECT AVG(number_products) FROM shop) </s>
find the name of employee who was awarded the most times in the evaluation.
CREATE TABLE evaluation (Employee_ID VARCHAR); CREATE TABLE employee (name VARCHAR, Employee_ID VARCHAR)
SELECT TOP 1 t1.name FROM employee AS t1 JOIN evaluation AS t2 ON t1.Employee_ID = t2.Employee_ID GROUP BY t2.Employee_ID ORDER BY COUNT(*) DESC
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE evaluation (Employee_ID VARCHAR); CREATE TABLE employee (name VARCHAR, Employee_ID VARCHAR) Question: find the name of employee who was awarded the most times in the evaluation. [/INST] SELECT TOP 1 t1.name FROM employee AS t1 JOIN evaluation AS t2 ON t1.Employee_ID = t2.Employee_ID GROUP BY t2.Employee_ID ORDER BY COUNT(*) DESC </s>
Find the name of the employee who got the highest one time bonus.
CREATE TABLE evaluation (Employee_ID VARCHAR, bonus VARCHAR); CREATE TABLE employee (name VARCHAR, Employee_ID VARCHAR)
SELECT TOP 1 t1.name FROM employee AS t1 JOIN evaluation AS t2 ON t1.Employee_ID = t2.Employee_ID ORDER BY t2.bonus DESC
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE evaluation (Employee_ID VARCHAR, bonus VARCHAR); CREATE TABLE employee (name VARCHAR, Employee_ID VARCHAR) Question: Find the name of the employee who got the highest one time bonus. [/INST] SELECT TOP 1 t1.name FROM employee AS t1 JOIN evaluation AS t2 ON t1.Employee_ID = t2.Employee_ID ORDER BY t2.bonus DESC </s>
Find the names of employees who never won any award in the evaluation.
CREATE TABLE evaluation (name VARCHAR, Employee_ID VARCHAR); CREATE TABLE employee (name VARCHAR, Employee_ID VARCHAR)
SELECT name FROM employee WHERE NOT Employee_ID IN (SELECT Employee_ID FROM evaluation)
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE evaluation (name VARCHAR, Employee_ID VARCHAR); CREATE TABLE employee (name VARCHAR, Employee_ID VARCHAR) Question: Find the names of employees who never won any award in the evaluation. [/INST] SELECT name FROM employee WHERE NOT Employee_ID IN (SELECT Employee_ID FROM evaluation) </s>
What is the name of the shop that is hiring the largest number of employees?
CREATE TABLE shop (name VARCHAR, shop_id VARCHAR); CREATE TABLE hiring (shop_id VARCHAR)
SELECT TOP 1 t2.name FROM hiring AS t1 JOIN shop AS t2 ON t1.shop_id = t2.shop_id GROUP BY t1.shop_id ORDER BY COUNT(*) DESC
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE shop (name VARCHAR, shop_id VARCHAR); CREATE TABLE hiring (shop_id VARCHAR) Question: What is the name of the shop that is hiring the largest number of employees? [/INST] SELECT TOP 1 t2.name FROM hiring AS t1 JOIN shop AS t2 ON t1.shop_id = t2.shop_id GROUP BY t1.shop_id ORDER BY COUNT(*) DESC </s>
Find the name of the shops that do not hire any employee.
CREATE TABLE shop (name VARCHAR, shop_id VARCHAR); CREATE TABLE hiring (name VARCHAR, shop_id VARCHAR)
SELECT name FROM shop WHERE NOT shop_id IN (SELECT shop_id FROM hiring)
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE shop (name VARCHAR, shop_id VARCHAR); CREATE TABLE hiring (name VARCHAR, shop_id VARCHAR) Question: Find the name of the shops that do not hire any employee. [/INST] SELECT name FROM shop WHERE NOT shop_id IN (SELECT shop_id FROM hiring) </s>
Find the number of employees hired in each shop; show the shop name as well.
CREATE TABLE shop (name VARCHAR, shop_id VARCHAR); CREATE TABLE hiring (shop_id VARCHAR)
SELECT COUNT(*), t2.name FROM hiring AS t1 JOIN shop AS t2 ON t1.shop_id = t2.shop_id GROUP BY t2.name
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE shop (name VARCHAR, shop_id VARCHAR); CREATE TABLE hiring (shop_id VARCHAR) Question: Find the number of employees hired in each shop; show the shop name as well. [/INST] SELECT COUNT(*), t2.name FROM hiring AS t1 JOIN shop AS t2 ON t1.shop_id = t2.shop_id GROUP BY t2.name </s>
What is total bonus given in all evaluations?
CREATE TABLE evaluation (bonus INTEGER)
SELECT SUM(bonus) FROM evaluation
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE evaluation (bonus INTEGER) Question: What is total bonus given in all evaluations? [/INST] SELECT SUM(bonus) FROM evaluation </s>
Give me all the information about hiring.
CREATE TABLE hiring (Id VARCHAR)
SELECT * FROM hiring
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE hiring (Id VARCHAR) Question: Give me all the information about hiring. [/INST] SELECT * FROM hiring </s>
Which district has both stores with less than 3000 products and stores with more than 10000 products?
CREATE TABLE shop (district VARCHAR, Number_products INTEGER)
SELECT district FROM shop WHERE Number_products < 3000 INTERSECT SELECT district FROM shop WHERE Number_products > 10000
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE shop (district VARCHAR, Number_products INTEGER) Question: Which district has both stores with less than 3000 products and stores with more than 10000 products? [/INST] SELECT district FROM shop WHERE Number_products < 3000 INTERSECT SELECT district FROM shop WHERE Number_products > 10000 </s>
How many different store locations are there?
CREATE TABLE shop (LOCATION VARCHAR)
SELECT COUNT(DISTINCT LOCATION) FROM shop
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE shop (LOCATION VARCHAR) Question: How many different store locations are there? [/INST] SELECT COUNT(DISTINCT LOCATION) FROM shop </s>
List document IDs, document names, and document descriptions for all documents.
CREATE TABLE Documents (document_id VARCHAR, document_name VARCHAR, document_description VARCHAR)
SELECT document_id, document_name, document_description FROM Documents
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Documents (document_id VARCHAR, document_name VARCHAR, document_description VARCHAR) Question: List document IDs, document names, and document descriptions for all documents. [/INST] SELECT document_id, document_name, document_description FROM Documents </s>
What is the document name and template id for document with description with the letter 'w' in it?
CREATE TABLE Documents (document_name VARCHAR, template_id VARCHAR, Document_Description VARCHAR)
SELECT document_name, template_id FROM Documents WHERE Document_Description LIKE "%w%"
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Documents (document_name VARCHAR, template_id VARCHAR, Document_Description VARCHAR) Question: What is the document name and template id for document with description with the letter 'w' in it? [/INST] SELECT document_name, template_id FROM Documents WHERE Document_Description LIKE "%w%" </s>
What is the document id, template id and description for document named "Robbin CV"?
CREATE TABLE Documents (document_id VARCHAR, template_id VARCHAR, Document_Description VARCHAR, document_name VARCHAR)
SELECT document_id, template_id, Document_Description FROM Documents WHERE document_name = "Robbin CV"
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Documents (document_id VARCHAR, template_id VARCHAR, Document_Description VARCHAR, document_name VARCHAR) Question: What is the document id, template id and description for document named "Robbin CV"? [/INST] SELECT document_id, template_id, Document_Description FROM Documents WHERE document_name = "Robbin CV" </s>
How many different templates do all document use?
CREATE TABLE Documents (template_id VARCHAR)
SELECT COUNT(DISTINCT template_id) FROM Documents
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Documents (template_id VARCHAR) Question: How many different templates do all document use? [/INST] SELECT COUNT(DISTINCT template_id) FROM Documents </s>
How many documents are using the template with type code 'PPT'?
CREATE TABLE Templates (Template_ID VARCHAR, Template_Type_Code VARCHAR); CREATE TABLE Documents (Template_ID VARCHAR)
SELECT COUNT(*) FROM Documents AS T1 JOIN Templates AS T2 ON T1.Template_ID = T2.Template_ID WHERE T2.Template_Type_Code = 'PPT'
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Templates (Template_ID VARCHAR, Template_Type_Code VARCHAR); CREATE TABLE Documents (Template_ID VARCHAR) Question: How many documents are using the template with type code 'PPT'? [/INST] SELECT COUNT(*) FROM Documents AS T1 JOIN Templates AS T2 ON T1.Template_ID = T2.Template_ID WHERE T2.Template_Type_Code = 'PPT' </s>
Show all template ids and number of documents using each template.
CREATE TABLE Documents (template_id VARCHAR)
SELECT template_id, COUNT(*) FROM Documents GROUP BY template_id
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Documents (template_id VARCHAR) Question: Show all template ids and number of documents using each template. [/INST] SELECT template_id, COUNT(*) FROM Documents GROUP BY template_id </s>
What is the id and type code for the template used by the most documents?
CREATE TABLE Documents (template_id VARCHAR); CREATE TABLE Templates (Template_Type_Code VARCHAR, template_id VARCHAR)
SELECT TOP 1 T1.template_id, T2.Template_Type_Code FROM Documents AS T1 JOIN Templates AS T2 ON T1.template_id = T2.template_id GROUP BY T1.template_id ORDER BY COUNT(*) DESC
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Documents (template_id VARCHAR); CREATE TABLE Templates (Template_Type_Code VARCHAR, template_id VARCHAR) Question: What is the id and type code for the template used by the most documents? [/INST] SELECT TOP 1 T1.template_id, T2.Template_Type_Code FROM Documents AS T1 JOIN Templates AS T2 ON T1.template_id = T2.template_id GROUP BY T1.template_id ORDER BY COUNT(*) DESC </s>
Show ids for all templates that are used by more than one document.
CREATE TABLE Documents (template_id VARCHAR)
SELECT template_id FROM Documents GROUP BY template_id HAVING COUNT(*) > 1
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Documents (template_id VARCHAR) Question: Show ids for all templates that are used by more than one document. [/INST] SELECT template_id FROM Documents GROUP BY template_id HAVING COUNT(*) > 1 </s>
Show ids for all templates not used by any document.
CREATE TABLE Documents (template_id VARCHAR); CREATE TABLE Templates (template_id VARCHAR)
SELECT template_id FROM Templates EXCEPT SELECT template_id FROM Documents
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Documents (template_id VARCHAR); CREATE TABLE Templates (template_id VARCHAR) Question: Show ids for all templates not used by any document. [/INST] SELECT template_id FROM Templates EXCEPT SELECT template_id FROM Documents </s>
How many templates do we have?
CREATE TABLE Templates (Id VARCHAR)
SELECT COUNT(*) FROM Templates
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Templates (Id VARCHAR) Question: How many templates do we have? [/INST] SELECT COUNT(*) FROM Templates </s>
Show template ids, version numbers, and template type codes for all templates.
CREATE TABLE Templates (template_id VARCHAR, version_number VARCHAR, template_type_code VARCHAR)
SELECT template_id, version_number, template_type_code FROM Templates
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Templates (template_id VARCHAR, version_number VARCHAR, template_type_code VARCHAR) Question: Show template ids, version numbers, and template type codes for all templates. [/INST] SELECT template_id, version_number, template_type_code FROM Templates </s>
Show all distinct template type codes for all templates.
CREATE TABLE Templates (template_type_code VARCHAR)
SELECT DISTINCT template_type_code FROM Templates
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Templates (template_type_code VARCHAR) Question: Show all distinct template type codes for all templates. [/INST] SELECT DISTINCT template_type_code FROM Templates </s>
What are the ids of templates with template type code PP or PPT?
CREATE TABLE Templates (template_id VARCHAR, template_type_code VARCHAR)
SELECT template_id FROM Templates WHERE template_type_code = "PP" OR template_type_code = "PPT"
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Templates (template_id VARCHAR, template_type_code VARCHAR) Question: What are the ids of templates with template type code PP or PPT? [/INST] SELECT template_id FROM Templates WHERE template_type_code = "PP" OR template_type_code = "PPT" </s>
How many templates have template type code CV?
CREATE TABLE Templates (template_type_code VARCHAR)
SELECT COUNT(*) FROM Templates WHERE template_type_code = "CV"
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Templates (template_type_code VARCHAR) Question: How many templates have template type code CV? [/INST] SELECT COUNT(*) FROM Templates WHERE template_type_code = "CV" </s>
What is the version number and template type code for the template with version number later than 5?
CREATE TABLE Templates (version_number INTEGER, template_type_code VARCHAR)
SELECT version_number, template_type_code FROM Templates WHERE version_number > 5
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Templates (version_number INTEGER, template_type_code VARCHAR) Question: What is the version number and template type code for the template with version number later than 5? [/INST] SELECT version_number, template_type_code FROM Templates WHERE version_number > 5 </s>
Show all template type codes and number of templates for each.
CREATE TABLE Templates (template_type_code VARCHAR)
SELECT template_type_code, COUNT(*) FROM Templates GROUP BY template_type_code
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Templates (template_type_code VARCHAR) Question: Show all template type codes and number of templates for each. [/INST] SELECT template_type_code, COUNT(*) FROM Templates GROUP BY template_type_code </s>
Which template type code has most number of templates?
CREATE TABLE Templates (template_type_code VARCHAR)
SELECT TOP 1 template_type_code FROM Templates GROUP BY template_type_code ORDER BY COUNT(*) DESC
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Templates (template_type_code VARCHAR) Question: Which template type code has most number of templates? [/INST] SELECT TOP 1 template_type_code FROM Templates GROUP BY template_type_code ORDER BY COUNT(*) DESC </s>
Show all template type codes with less than three templates.
CREATE TABLE Templates (template_type_code VARCHAR)
SELECT template_type_code FROM Templates GROUP BY template_type_code HAVING COUNT(*) < 3
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Templates (template_type_code VARCHAR) Question: Show all template type codes with less than three templates. [/INST] SELECT template_type_code FROM Templates GROUP BY template_type_code HAVING COUNT(*) < 3 </s>
What the smallest version number and its template type code?
CREATE TABLE Templates (template_type_code VARCHAR, Version_Number INTEGER)
SELECT MIN(Version_Number), template_type_code FROM Templates
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Templates (template_type_code VARCHAR, Version_Number INTEGER) Question: What the smallest version number and its template type code? [/INST] SELECT MIN(Version_Number), template_type_code FROM Templates </s>
What is the template type code of the template used by document with the name "Data base"?
CREATE TABLE Templates (template_type_code VARCHAR, template_id VARCHAR); CREATE TABLE Documents (template_id VARCHAR, document_name VARCHAR)
SELECT T1.template_type_code FROM Templates AS T1 JOIN Documents AS T2 ON T1.template_id = T2.template_id WHERE T2.document_name = "Data base"
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Templates (template_type_code VARCHAR, template_id VARCHAR); CREATE TABLE Documents (template_id VARCHAR, document_name VARCHAR) Question: What is the template type code of the template used by document with the name "Data base"? [/INST] SELECT T1.template_type_code FROM Templates AS T1 JOIN Documents AS T2 ON T1.template_id = T2.template_id WHERE T2.document_name = "Data base" </s>
Show all document names using templates with template type code BK.
CREATE TABLE Documents (document_name VARCHAR, template_id VARCHAR); CREATE TABLE Templates (template_id VARCHAR, template_type_code VARCHAR)
SELECT T2.document_name FROM Templates AS T1 JOIN Documents AS T2 ON T1.template_id = T2.template_id WHERE T1.template_type_code = "BK"
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Documents (document_name VARCHAR, template_id VARCHAR); CREATE TABLE Templates (template_id VARCHAR, template_type_code VARCHAR) Question: Show all document names using templates with template type code BK. [/INST] SELECT T2.document_name FROM Templates AS T1 JOIN Documents AS T2 ON T1.template_id = T2.template_id WHERE T1.template_type_code = "BK" </s>
Show all template type codes and the number of documents using each type.
CREATE TABLE Documents (template_id VARCHAR); CREATE TABLE Templates (template_type_code VARCHAR, template_id VARCHAR)
SELECT T1.template_type_code, COUNT(*) FROM Templates AS T1 JOIN Documents AS T2 ON T1.template_id = T2.template_id GROUP BY T1.template_type_code
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Documents (template_id VARCHAR); CREATE TABLE Templates (template_type_code VARCHAR, template_id VARCHAR) Question: Show all template type codes and the number of documents using each type. [/INST] SELECT T1.template_type_code, COUNT(*) FROM Templates AS T1 JOIN Documents AS T2 ON T1.template_id = T2.template_id GROUP BY T1.template_type_code </s>
Which template type code is used by most number of documents?
CREATE TABLE Documents (template_id VARCHAR); CREATE TABLE Templates (template_type_code VARCHAR, template_id VARCHAR)
SELECT TOP 1 T1.template_type_code FROM Templates AS T1 JOIN Documents AS T2 ON T1.template_id = T2.template_id GROUP BY T1.template_type_code ORDER BY COUNT(*) DESC
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Documents (template_id VARCHAR); CREATE TABLE Templates (template_type_code VARCHAR, template_id VARCHAR) Question: Which template type code is used by most number of documents? [/INST] SELECT TOP 1 T1.template_type_code FROM Templates AS T1 JOIN Documents AS T2 ON T1.template_id = T2.template_id GROUP BY T1.template_type_code ORDER BY COUNT(*) DESC </s>
Show all template type codes that are not used by any document.
CREATE TABLE Documents (template_id VARCHAR); CREATE TABLE Templates (template_id VARCHAR); CREATE TABLE Templates (template_type_code VARCHAR)
SELECT template_type_code FROM Templates EXCEPT SELECT template_type_code FROM Templates AS T1 JOIN Documents AS T2 ON T1.template_id = T2.template_id
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Documents (template_id VARCHAR); CREATE TABLE Templates (template_id VARCHAR); CREATE TABLE Templates (template_type_code VARCHAR) Question: Show all template type codes that are not used by any document. [/INST] SELECT template_type_code FROM Templates EXCEPT SELECT template_type_code FROM Templates AS T1 JOIN Documents AS T2 ON T1.template_id = T2.template_id </s>
Show all template type codes and descriptions.
CREATE TABLE Ref_template_types (template_type_code VARCHAR, template_type_description VARCHAR)
SELECT template_type_code, template_type_description FROM Ref_template_types
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Ref_template_types (template_type_code VARCHAR, template_type_description VARCHAR) Question: Show all template type codes and descriptions. [/INST] SELECT template_type_code, template_type_description FROM Ref_template_types </s>
What is the template type descriptions for template type code "AD".
CREATE TABLE Ref_template_types (template_type_description VARCHAR, template_type_code VARCHAR)
SELECT template_type_description FROM Ref_template_types WHERE template_type_code = "AD"
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Ref_template_types (template_type_description VARCHAR, template_type_code VARCHAR) Question: What is the template type descriptions for template type code "AD". [/INST] SELECT template_type_description FROM Ref_template_types WHERE template_type_code = "AD" </s>
What is the template type code for template type description "Book".
CREATE TABLE Ref_template_types (template_type_code VARCHAR, template_type_description VARCHAR)
SELECT template_type_code FROM Ref_template_types WHERE template_type_description = "Book"
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Ref_template_types (template_type_code VARCHAR, template_type_description VARCHAR) Question: What is the template type code for template type description "Book". [/INST] SELECT template_type_code FROM Ref_template_types WHERE template_type_description = "Book" </s>
What are the distinct template type descriptions for the templates ever used by any document?
CREATE TABLE Templates (template_type_code VARCHAR, Template_ID VARCHAR); CREATE TABLE Documents (template_ID VARCHAR); CREATE TABLE Ref_template_types (template_type_description VARCHAR, template_type_code VARCHAR)
SELECT DISTINCT T1.template_type_description FROM Ref_template_types AS T1 JOIN Templates AS T2 ON T1.template_type_code = T2.template_type_code JOIN Documents AS T3 ON T2.Template_ID = T3.template_ID
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Templates (template_type_code VARCHAR, Template_ID VARCHAR); CREATE TABLE Documents (template_ID VARCHAR); CREATE TABLE Ref_template_types (template_type_description VARCHAR, template_type_code VARCHAR) Question: What are the distinct template type descriptions for the templates ever used by any document? [/INST] SELECT DISTINCT T1.template_type_description FROM Ref_template_types AS T1 JOIN Templates AS T2 ON T1.template_type_code = T2.template_type_code JOIN Documents AS T3 ON T2.Template_ID = T3.template_ID </s>
What are the template ids with template type description "Presentation".
CREATE TABLE Templates (template_id VARCHAR, template_type_code VARCHAR); CREATE TABLE Ref_template_types (template_type_code VARCHAR, template_type_description VARCHAR)
SELECT T2.template_id FROM Ref_template_types AS T1 JOIN Templates AS T2 ON T1.template_type_code = T2.template_type_code WHERE T1.template_type_description = "Presentation"
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Templates (template_id VARCHAR, template_type_code VARCHAR); CREATE TABLE Ref_template_types (template_type_code VARCHAR, template_type_description VARCHAR) Question: What are the template ids with template type description "Presentation". [/INST] SELECT T2.template_id FROM Ref_template_types AS T1 JOIN Templates AS T2 ON T1.template_type_code = T2.template_type_code WHERE T1.template_type_description = "Presentation" </s>
How many paragraphs in total?
CREATE TABLE Paragraphs (Id VARCHAR)
SELECT COUNT(*) FROM Paragraphs
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Paragraphs (Id VARCHAR) Question: How many paragraphs in total? [/INST] SELECT COUNT(*) FROM Paragraphs </s>
How many paragraphs for the document with name 'Summer Show'?
CREATE TABLE Documents (document_ID VARCHAR, document_name VARCHAR); CREATE TABLE Paragraphs (document_ID VARCHAR)
SELECT COUNT(*) FROM Paragraphs AS T1 JOIN Documents AS T2 ON T1.document_ID = T2.document_ID WHERE T2.document_name = 'Summer Show'
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Documents (document_ID VARCHAR, document_name VARCHAR); CREATE TABLE Paragraphs (document_ID VARCHAR) Question: How many paragraphs for the document with name 'Summer Show'? [/INST] SELECT COUNT(*) FROM Paragraphs AS T1 JOIN Documents AS T2 ON T1.document_ID = T2.document_ID WHERE T2.document_name = 'Summer Show' </s>
Show paragraph details for paragraph with text 'Korea ' .
CREATE TABLE paragraphs (other_details VARCHAR, paragraph_text VARCHAR)
SELECT other_details FROM paragraphs WHERE paragraph_text LIKE 'korea'
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE paragraphs (other_details VARCHAR, paragraph_text VARCHAR) Question: Show paragraph details for paragraph with text 'Korea ' . [/INST] SELECT other_details FROM paragraphs WHERE paragraph_text LIKE 'korea' </s>
Show all paragraph ids and texts for the document with name 'Welcome to NY'.
CREATE TABLE Documents (document_id VARCHAR, Document_Name VARCHAR); CREATE TABLE Paragraphs (paragraph_id VARCHAR, paragraph_text VARCHAR, document_id VARCHAR)
SELECT T1.paragraph_id, T1.paragraph_text FROM Paragraphs AS T1 JOIN Documents AS T2 ON T1.document_id = T2.document_id WHERE T2.Document_Name = 'Welcome to NY'
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Documents (document_id VARCHAR, Document_Name VARCHAR); CREATE TABLE Paragraphs (paragraph_id VARCHAR, paragraph_text VARCHAR, document_id VARCHAR) Question: Show all paragraph ids and texts for the document with name 'Welcome to NY'. [/INST] SELECT T1.paragraph_id, T1.paragraph_text FROM Paragraphs AS T1 JOIN Documents AS T2 ON T1.document_id = T2.document_id WHERE T2.Document_Name = 'Welcome to NY' </s>
Show all paragraph texts for the document "Customer reviews".
CREATE TABLE Paragraphs (paragraph_text VARCHAR, document_id VARCHAR); CREATE TABLE Documents (document_id VARCHAR, document_name VARCHAR)
SELECT T1.paragraph_text FROM Paragraphs AS T1 JOIN Documents AS T2 ON T1.document_id = T2.document_id WHERE T2.document_name = "Customer reviews"
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Paragraphs (paragraph_text VARCHAR, document_id VARCHAR); CREATE TABLE Documents (document_id VARCHAR, document_name VARCHAR) Question: Show all paragraph texts for the document "Customer reviews". [/INST] SELECT T1.paragraph_text FROM Paragraphs AS T1 JOIN Documents AS T2 ON T1.document_id = T2.document_id WHERE T2.document_name = "Customer reviews" </s>
Show all document ids and the number of paragraphs in each document. Order by document id.
CREATE TABLE Paragraphs (document_id VARCHAR)
SELECT document_id, COUNT(*) FROM Paragraphs GROUP BY document_id ORDER BY document_id
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Paragraphs (document_id VARCHAR) Question: Show all document ids and the number of paragraphs in each document. Order by document id. [/INST] SELECT document_id, COUNT(*) FROM Paragraphs GROUP BY document_id ORDER BY document_id </s>
Show all document ids, names and the number of paragraphs in each document.
CREATE TABLE Documents (document_name VARCHAR, document_id VARCHAR); CREATE TABLE Paragraphs (document_id VARCHAR)
SELECT T1.document_id, T2.document_name, COUNT(*) FROM Paragraphs AS T1 JOIN Documents AS T2 ON T1.document_id = T2.document_id GROUP BY T1.document_id
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Documents (document_name VARCHAR, document_id VARCHAR); CREATE TABLE Paragraphs (document_id VARCHAR) Question: Show all document ids, names and the number of paragraphs in each document. [/INST] SELECT T1.document_id, T2.document_name, COUNT(*) FROM Paragraphs AS T1 JOIN Documents AS T2 ON T1.document_id = T2.document_id GROUP BY T1.document_id </s>
List all document ids with at least two paragraphs.
CREATE TABLE Paragraphs (document_id VARCHAR)
SELECT document_id FROM Paragraphs GROUP BY document_id HAVING COUNT(*) >= 2
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Paragraphs (document_id VARCHAR) Question: List all document ids with at least two paragraphs. [/INST] SELECT document_id FROM Paragraphs GROUP BY document_id HAVING COUNT(*) >= 2 </s>
What is the document id and name with greatest number of paragraphs?
CREATE TABLE Documents (document_name VARCHAR, document_id VARCHAR); CREATE TABLE Paragraphs (document_id VARCHAR)
SELECT TOP 1 T1.document_id, T2.document_name FROM Paragraphs AS T1 JOIN Documents AS T2 ON T1.document_id = T2.document_id GROUP BY T1.document_id ORDER BY COUNT(*) DESC
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Documents (document_name VARCHAR, document_id VARCHAR); CREATE TABLE Paragraphs (document_id VARCHAR) Question: What is the document id and name with greatest number of paragraphs? [/INST] SELECT TOP 1 T1.document_id, T2.document_name FROM Paragraphs AS T1 JOIN Documents AS T2 ON T1.document_id = T2.document_id GROUP BY T1.document_id ORDER BY COUNT(*) DESC </s>
What is the document id with least number of paragraphs?
CREATE TABLE Paragraphs (document_id VARCHAR)
SELECT TOP 1 document_id FROM Paragraphs GROUP BY document_id ORDER BY COUNT(*)
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Paragraphs (document_id VARCHAR) Question: What is the document id with least number of paragraphs? [/INST] SELECT TOP 1 document_id FROM Paragraphs GROUP BY document_id ORDER BY COUNT(*) </s>
What is the document id with 1 to 2 paragraphs?
CREATE TABLE Paragraphs (document_id VARCHAR)
SELECT document_id FROM Paragraphs GROUP BY document_id HAVING COUNT(*) BETWEEN 1 AND 2
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Paragraphs (document_id VARCHAR) Question: What is the document id with 1 to 2 paragraphs? [/INST] SELECT document_id FROM Paragraphs GROUP BY document_id HAVING COUNT(*) BETWEEN 1 AND 2 </s>
Show the document id with paragraph text 'Brazil' and 'Ireland'.
CREATE TABLE Paragraphs (document_id VARCHAR, paragraph_text VARCHAR)
SELECT document_id FROM Paragraphs WHERE paragraph_text = 'Brazil' INTERSECT SELECT document_id FROM Paragraphs WHERE paragraph_text = 'Ireland'
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Paragraphs (document_id VARCHAR, paragraph_text VARCHAR) Question: Show the document id with paragraph text 'Brazil' and 'Ireland'. [/INST] SELECT document_id FROM Paragraphs WHERE paragraph_text = 'Brazil' INTERSECT SELECT document_id FROM Paragraphs WHERE paragraph_text = 'Ireland' </s>
How many teachers are there?
CREATE TABLE teacher (Id VARCHAR)
SELECT COUNT(*) FROM teacher
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE teacher (Id VARCHAR) Question: How many teachers are there? [/INST] SELECT COUNT(*) FROM teacher </s>
List the names of teachers in ascending order of age.
CREATE TABLE teacher (Name VARCHAR, Age VARCHAR)
SELECT Name FROM teacher ORDER BY Age
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE teacher (Name VARCHAR, Age VARCHAR) Question: List the names of teachers in ascending order of age. [/INST] SELECT Name FROM teacher ORDER BY Age </s>
What are the age and hometown of teachers?
CREATE TABLE teacher (Age VARCHAR, Hometown VARCHAR)
SELECT Age, Hometown FROM teacher
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE teacher (Age VARCHAR, Hometown VARCHAR) Question: What are the age and hometown of teachers? [/INST] SELECT Age, Hometown FROM teacher </s>
List the name of teachers whose hometown is not `` Little Lever Urban District '' .
CREATE TABLE teacher (name VARCHAR, hometown VARCHAR)
SELECT name FROM teacher WHERE hometown <> "little lever urban district"
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE teacher (name VARCHAR, hometown VARCHAR) Question: List the name of teachers whose hometown is not `` Little Lever Urban District '' . [/INST] SELECT name FROM teacher WHERE hometown <> "little lever urban district" </s>
Show the name of teachers aged either 32 or 33?
CREATE TABLE teacher (Name VARCHAR, Age VARCHAR)
SELECT Name FROM teacher WHERE Age = 32 OR Age = 33
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE teacher (Name VARCHAR, Age VARCHAR) Question: Show the name of teachers aged either 32 or 33? [/INST] SELECT Name FROM teacher WHERE Age = 32 OR Age = 33 </s>
What is the hometown of the youngest teacher?
CREATE TABLE teacher (Hometown VARCHAR, Age VARCHAR)
SELECT TOP 1 Hometown FROM teacher ORDER BY Age
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE teacher (Hometown VARCHAR, Age VARCHAR) Question: What is the hometown of the youngest teacher? [/INST] SELECT TOP 1 Hometown FROM teacher ORDER BY Age </s>
Show different hometown of teachers and the number of teachers from each hometown.
CREATE TABLE teacher (Hometown VARCHAR)
SELECT Hometown, COUNT(*) FROM teacher GROUP BY Hometown
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE teacher (Hometown VARCHAR) Question: Show different hometown of teachers and the number of teachers from each hometown. [/INST] SELECT Hometown, COUNT(*) FROM teacher GROUP BY Hometown </s>
List the most common hometown of teachers.
CREATE TABLE teacher (Hometown VARCHAR)
SELECT TOP 1 Hometown FROM teacher GROUP BY Hometown ORDER BY COUNT(*) DESC
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE teacher (Hometown VARCHAR) Question: List the most common hometown of teachers. [/INST] SELECT TOP 1 Hometown FROM teacher GROUP BY Hometown ORDER BY COUNT(*) DESC </s>
Show the hometowns shared by at least two teachers.
CREATE TABLE teacher (Hometown VARCHAR)
SELECT Hometown FROM teacher GROUP BY Hometown HAVING COUNT(*) >= 2
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE teacher (Hometown VARCHAR) Question: Show the hometowns shared by at least two teachers. [/INST] SELECT Hometown FROM teacher GROUP BY Hometown HAVING COUNT(*) >= 2 </s>
Show names of teachers and the courses they are arranged to teach.
CREATE TABLE course_arrange (Course_ID VARCHAR, Teacher_ID VARCHAR); CREATE TABLE teacher (Name VARCHAR, Teacher_ID VARCHAR); CREATE TABLE course (Course VARCHAR, Course_ID VARCHAR)
SELECT T3.Name, T2.Course FROM course_arrange AS T1 JOIN course AS T2 ON T1.Course_ID = T2.Course_ID JOIN teacher AS T3 ON T1.Teacher_ID = T3.Teacher_ID
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE course_arrange (Course_ID VARCHAR, Teacher_ID VARCHAR); CREATE TABLE teacher (Name VARCHAR, Teacher_ID VARCHAR); CREATE TABLE course (Course VARCHAR, Course_ID VARCHAR) Question: Show names of teachers and the courses they are arranged to teach. [/INST] SELECT T3.Name, T2.Course FROM course_arrange AS T1 JOIN course AS T2 ON T1.Course_ID = T2.Course_ID JOIN teacher AS T3 ON T1.Teacher_ID = T3.Teacher_ID </s>
Show names of teachers and the courses they are arranged to teach in ascending alphabetical order of the teacher's name.
CREATE TABLE course_arrange (Course_ID VARCHAR, Teacher_ID VARCHAR); CREATE TABLE teacher (Name VARCHAR, Teacher_ID VARCHAR); CREATE TABLE course (Course VARCHAR, Course_ID VARCHAR)
SELECT T3.Name, T2.Course FROM course_arrange AS T1 JOIN course AS T2 ON T1.Course_ID = T2.Course_ID JOIN teacher AS T3 ON T1.Teacher_ID = T3.Teacher_ID ORDER BY T3.Name
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE course_arrange (Course_ID VARCHAR, Teacher_ID VARCHAR); CREATE TABLE teacher (Name VARCHAR, Teacher_ID VARCHAR); CREATE TABLE course (Course VARCHAR, Course_ID VARCHAR) Question: Show names of teachers and the courses they are arranged to teach in ascending alphabetical order of the teacher's name. [/INST] SELECT T3.Name, T2.Course FROM course_arrange AS T1 JOIN course AS T2 ON T1.Course_ID = T2.Course_ID JOIN teacher AS T3 ON T1.Teacher_ID = T3.Teacher_ID ORDER BY T3.Name </s>
Show the name of the teacher for the math course.
CREATE TABLE course_arrange (Course_ID VARCHAR, Teacher_ID VARCHAR); CREATE TABLE course (Course_ID VARCHAR, Course VARCHAR); CREATE TABLE teacher (Name VARCHAR, Teacher_ID VARCHAR)
SELECT T3.Name FROM course_arrange AS T1 JOIN course AS T2 ON T1.Course_ID = T2.Course_ID JOIN teacher AS T3 ON T1.Teacher_ID = T3.Teacher_ID WHERE T2.Course = "Math"
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE course_arrange (Course_ID VARCHAR, Teacher_ID VARCHAR); CREATE TABLE course (Course_ID VARCHAR, Course VARCHAR); CREATE TABLE teacher (Name VARCHAR, Teacher_ID VARCHAR) Question: Show the name of the teacher for the math course. [/INST] SELECT T3.Name FROM course_arrange AS T1 JOIN course AS T2 ON T1.Course_ID = T2.Course_ID JOIN teacher AS T3 ON T1.Teacher_ID = T3.Teacher_ID WHERE T2.Course = "Math" </s>
Show names of teachers and the number of courses they teach.
CREATE TABLE teacher (Name VARCHAR, Teacher_ID VARCHAR); CREATE TABLE course_arrange (Teacher_ID VARCHAR)
SELECT T2.Name, COUNT(*) FROM course_arrange AS T1 JOIN teacher AS T2 ON T1.Teacher_ID = T2.Teacher_ID GROUP BY T2.Name
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE teacher (Name VARCHAR, Teacher_ID VARCHAR); CREATE TABLE course_arrange (Teacher_ID VARCHAR) Question: Show names of teachers and the number of courses they teach. [/INST] SELECT T2.Name, COUNT(*) FROM course_arrange AS T1 JOIN teacher AS T2 ON T1.Teacher_ID = T2.Teacher_ID GROUP BY T2.Name </s>
Show names of teachers that teach at least two courses.
CREATE TABLE teacher (Name VARCHAR, Teacher_ID VARCHAR); CREATE TABLE course_arrange (Teacher_ID VARCHAR)
SELECT T2.Name FROM course_arrange AS T1 JOIN teacher AS T2 ON T1.Teacher_ID = T2.Teacher_ID GROUP BY T2.Name HAVING COUNT(*) >= 2
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE teacher (Name VARCHAR, Teacher_ID VARCHAR); CREATE TABLE course_arrange (Teacher_ID VARCHAR) Question: Show names of teachers that teach at least two courses. [/INST] SELECT T2.Name FROM course_arrange AS T1 JOIN teacher AS T2 ON T1.Teacher_ID = T2.Teacher_ID GROUP BY T2.Name HAVING COUNT(*) >= 2 </s>
List the names of teachers who have not been arranged to teach courses.
CREATE TABLE course_arrange (Name VARCHAR, Teacher_id VARCHAR); CREATE TABLE teacher (Name VARCHAR, Teacher_id VARCHAR)
SELECT Name FROM teacher WHERE NOT Teacher_id IN (SELECT Teacher_id FROM course_arrange)
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE course_arrange (Name VARCHAR, Teacher_id VARCHAR); CREATE TABLE teacher (Name VARCHAR, Teacher_id VARCHAR) Question: List the names of teachers who have not been arranged to teach courses. [/INST] SELECT Name FROM teacher WHERE NOT Teacher_id IN (SELECT Teacher_id FROM course_arrange) </s>
How many visitors below age 30 are there?
CREATE TABLE visitor (age INTEGER)
SELECT COUNT(*) FROM visitor WHERE age < 30
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE visitor (age INTEGER) Question: How many visitors below age 30 are there? [/INST] SELECT COUNT(*) FROM visitor WHERE age < 30 </s>
Find the names of the visitors whose membership level is higher than 4, and order the results by the level from high to low.
CREATE TABLE visitor (name VARCHAR, Level_of_membership INTEGER)
SELECT name FROM visitor WHERE Level_of_membership > 4 ORDER BY Level_of_membership DESC
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE visitor (name VARCHAR, Level_of_membership INTEGER) Question: Find the names of the visitors whose membership level is higher than 4, and order the results by the level from high to low. [/INST] SELECT name FROM visitor WHERE Level_of_membership > 4 ORDER BY Level_of_membership DESC </s>
What is the average age of the visitors whose membership level is not higher than 4?
CREATE TABLE visitor (age INTEGER, Level_of_membership VARCHAR)
SELECT AVG(age) FROM visitor WHERE Level_of_membership <= 4
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE visitor (age INTEGER, Level_of_membership VARCHAR) Question: What is the average age of the visitors whose membership level is not higher than 4? [/INST] SELECT AVG(age) FROM visitor WHERE Level_of_membership <= 4 </s>
Find the name and membership level of the visitors whose membership level is higher than 4, and sort by their age from old to young.
CREATE TABLE visitor (name VARCHAR, Level_of_membership INTEGER, age VARCHAR)
SELECT name, Level_of_membership FROM visitor WHERE Level_of_membership > 4 ORDER BY age DESC
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE visitor (name VARCHAR, Level_of_membership INTEGER, age VARCHAR) Question: Find the name and membership level of the visitors whose membership level is higher than 4, and sort by their age from old to young. [/INST] SELECT name, Level_of_membership FROM visitor WHERE Level_of_membership > 4 ORDER BY age DESC </s>
Find the id and name of the museum that has the most staff members?
CREATE TABLE museum (museum_id VARCHAR, name VARCHAR, num_of_staff VARCHAR)
SELECT TOP 1 museum_id, name FROM museum ORDER BY num_of_staff DESC
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE museum (museum_id VARCHAR, name VARCHAR, num_of_staff VARCHAR) Question: Find the id and name of the museum that has the most staff members? [/INST] SELECT TOP 1 museum_id, name FROM museum ORDER BY num_of_staff DESC </s>
Find the average number of staff working for the museums that were open before 2009.
CREATE TABLE museum (num_of_staff INTEGER, open_year INTEGER)
SELECT AVG(num_of_staff) FROM museum WHERE open_year < 2009
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE museum (num_of_staff INTEGER, open_year INTEGER) Question: Find the average number of staff working for the museums that were open before 2009. [/INST] SELECT AVG(num_of_staff) FROM museum WHERE open_year < 2009 </s>
What are the opening year and staff number of the museum named Plaza Museum?
CREATE TABLE museum (Num_of_Staff VARCHAR, Open_Year VARCHAR, name VARCHAR)
SELECT Num_of_Staff, Open_Year FROM museum WHERE name = 'Plaza Museum'
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE museum (Num_of_Staff VARCHAR, Open_Year VARCHAR, name VARCHAR) Question: What are the opening year and staff number of the museum named Plaza Museum? [/INST] SELECT Num_of_Staff, Open_Year FROM museum WHERE name = 'Plaza Museum' </s>
find the names of museums which have more staff than the minimum staff number of all museums opened after 2010.
CREATE TABLE museum (name VARCHAR, num_of_staff INTEGER, open_year INTEGER)
SELECT name FROM museum WHERE num_of_staff > (SELECT MIN(num_of_staff) FROM museum WHERE open_year > 2010)
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE museum (name VARCHAR, num_of_staff INTEGER, open_year INTEGER) Question: find the names of museums which have more staff than the minimum staff number of all museums opened after 2010. [/INST] SELECT name FROM museum WHERE num_of_staff > (SELECT MIN(num_of_staff) FROM museum WHERE open_year > 2010) </s>
find the id, name and age for visitors who visited some museums more than once.
CREATE TABLE visit (visitor_id VARCHAR); CREATE TABLE visitor (id VARCHAR, name VARCHAR, age VARCHAR)
SELECT t1.id, t1.name, t1.age FROM visitor AS t1 JOIN visit AS t2 ON t1.id = t2.visitor_id GROUP BY t1.id HAVING COUNT(*) > 1
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE visit (visitor_id VARCHAR); CREATE TABLE visitor (id VARCHAR, name VARCHAR, age VARCHAR) Question: find the id, name and age for visitors who visited some museums more than once. [/INST] SELECT t1.id, t1.name, t1.age FROM visitor AS t1 JOIN visit AS t2 ON t1.id = t2.visitor_id GROUP BY t1.id HAVING COUNT(*) > 1 </s>
What are the id, name and membership level of visitors who have spent the largest amount of money in total in all museum tickets?
CREATE TABLE visit (visitor_id VARCHAR, Total_spent INTEGER); CREATE TABLE visitor (name VARCHAR, Level_of_membership VARCHAR, id VARCHAR)
SELECT TOP 1 t2.visitor_id, t1.name, t1.Level_of_membership FROM visitor AS t1 JOIN visit AS t2 ON t1.id = t2.visitor_id GROUP BY t2.visitor_id ORDER BY SUM(t2.Total_spent) DESC
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE visit (visitor_id VARCHAR, Total_spent INTEGER); CREATE TABLE visitor (name VARCHAR, Level_of_membership VARCHAR, id VARCHAR) Question: What are the id, name and membership level of visitors who have spent the largest amount of money in total in all museum tickets? [/INST] SELECT TOP 1 t2.visitor_id, t1.name, t1.Level_of_membership FROM visitor AS t1 JOIN visit AS t2 ON t1.id = t2.visitor_id GROUP BY t2.visitor_id ORDER BY SUM(t2.Total_spent) DESC </s>
What are the id and name of the museum visited most times?
CREATE TABLE museum (name VARCHAR, Museum_ID VARCHAR); CREATE TABLE visit (Museum_ID VARCHAR)
SELECT TOP 1 t2.Museum_ID, t1.name FROM museum AS t1 JOIN visit AS t2 ON t1.Museum_ID = t2.Museum_ID GROUP BY t2.Museum_ID ORDER BY COUNT(*) DESC
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE museum (name VARCHAR, Museum_ID VARCHAR); CREATE TABLE visit (Museum_ID VARCHAR) Question: What are the id and name of the museum visited most times? [/INST] SELECT TOP 1 t2.Museum_ID, t1.name FROM museum AS t1 JOIN visit AS t2 ON t1.Museum_ID = t2.Museum_ID GROUP BY t2.Museum_ID ORDER BY COUNT(*) DESC </s>
What is the name of the museum that had no visitor yet?
CREATE TABLE visit (name VARCHAR, Museum_ID VARCHAR, museum_id VARCHAR); CREATE TABLE museum (name VARCHAR, Museum_ID VARCHAR, museum_id VARCHAR)
SELECT name FROM museum WHERE NOT Museum_ID IN (SELECT museum_id FROM visit)
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE visit (name VARCHAR, Museum_ID VARCHAR, museum_id VARCHAR); CREATE TABLE museum (name VARCHAR, Museum_ID VARCHAR, museum_id VARCHAR) Question: What is the name of the museum that had no visitor yet? [/INST] SELECT name FROM museum WHERE NOT Museum_ID IN (SELECT museum_id FROM visit) </s>
Find the name and age of the visitor who bought the most tickets at once.
CREATE TABLE visitor (name VARCHAR, age VARCHAR, id VARCHAR); CREATE TABLE visit (visitor_id VARCHAR, num_of_ticket VARCHAR)
SELECT TOP 1 t1.name, t1.age FROM visitor AS t1 JOIN visit AS t2 ON t1.id = t2.visitor_id ORDER BY t2.num_of_ticket DESC
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE visitor (name VARCHAR, age VARCHAR, id VARCHAR); CREATE TABLE visit (visitor_id VARCHAR, num_of_ticket VARCHAR) Question: Find the name and age of the visitor who bought the most tickets at once. [/INST] SELECT TOP 1 t1.name, t1.age FROM visitor AS t1 JOIN visit AS t2 ON t1.id = t2.visitor_id ORDER BY t2.num_of_ticket DESC </s>
What are the average and maximum number of tickets bought in all visits?
CREATE TABLE visit (num_of_ticket INTEGER)
SELECT AVG(num_of_ticket), MAX(num_of_ticket) FROM visit
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE visit (num_of_ticket INTEGER) Question: What are the average and maximum number of tickets bought in all visits? [/INST] SELECT AVG(num_of_ticket), MAX(num_of_ticket) FROM visit </s>
What is the total ticket expense of the visitors whose membership level is 1?
CREATE TABLE visit (Total_spent INTEGER, visitor_id VARCHAR); CREATE TABLE visitor (id VARCHAR, Level_of_membership VARCHAR)
SELECT SUM(t2.Total_spent) FROM visitor AS t1 JOIN visit AS t2 ON t1.id = t2.visitor_id WHERE t1.Level_of_membership = 1
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE visit (Total_spent INTEGER, visitor_id VARCHAR); CREATE TABLE visitor (id VARCHAR, Level_of_membership VARCHAR) Question: What is the total ticket expense of the visitors whose membership level is 1? [/INST] SELECT SUM(t2.Total_spent) FROM visitor AS t1 JOIN visit AS t2 ON t1.id = t2.visitor_id WHERE t1.Level_of_membership = 1 </s>
What is the name of the visitor who visited both a museum opened before 2009 and a museum opened after 2011?
CREATE TABLE visitor (name VARCHAR, id VARCHAR); CREATE TABLE museum (Museum_ID VARCHAR, open_year INTEGER); CREATE TABLE visit (visitor_id VARCHAR, Museum_ID VARCHAR)
SELECT t1.name FROM visitor AS t1 JOIN visit AS t2 ON t1.id = t2.visitor_id JOIN museum AS t3 ON t3.Museum_ID = t2.Museum_ID WHERE t3.open_year < 2009 INTERSECT SELECT t1.name FROM visitor AS t1 JOIN visit AS t2 ON t1.id = t2.visitor_id JOIN museum AS t3 ON t3.Museum_ID = t2.Museum_ID WHERE t3.open_year > 2011
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE visitor (name VARCHAR, id VARCHAR); CREATE TABLE museum (Museum_ID VARCHAR, open_year INTEGER); CREATE TABLE visit (visitor_id VARCHAR, Museum_ID VARCHAR) Question: What is the name of the visitor who visited both a museum opened before 2009 and a museum opened after 2011? [/INST] SELECT t1.name FROM visitor AS t1 JOIN visit AS t2 ON t1.id = t2.visitor_id JOIN museum AS t3 ON t3.Museum_ID = t2.Museum_ID WHERE t3.open_year < 2009 INTERSECT SELECT t1.name FROM visitor AS t1 JOIN visit AS t2 ON t1.id = t2.visitor_id JOIN museum AS t3 ON t3.Museum_ID = t2.Museum_ID WHERE t3.open_year > 2011 </s>
Find the number of visitors who did not visit any museum opened after 2010.
CREATE TABLE museum (Museum_ID VARCHAR, open_year INTEGER); CREATE TABLE visitor (id VARCHAR); CREATE TABLE visit (visitor_id VARCHAR, Museum_ID VARCHAR)
SELECT COUNT(*) FROM visitor WHERE NOT id IN (SELECT t2.visitor_id FROM museum AS t1 JOIN visit AS t2 ON t1.Museum_ID = t2.Museum_ID WHERE t1.open_year > 2010)
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE museum (Museum_ID VARCHAR, open_year INTEGER); CREATE TABLE visitor (id VARCHAR); CREATE TABLE visit (visitor_id VARCHAR, Museum_ID VARCHAR) Question: Find the number of visitors who did not visit any museum opened after 2010. [/INST] SELECT COUNT(*) FROM visitor WHERE NOT id IN (SELECT t2.visitor_id FROM museum AS t1 JOIN visit AS t2 ON t1.Museum_ID = t2.Museum_ID WHERE t1.open_year > 2010) </s>
How many museums were opened after 2013 or before 2008?
CREATE TABLE museum (open_year VARCHAR)
SELECT COUNT(*) FROM museum WHERE open_year > 2013 OR open_year < 2008
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE museum (open_year VARCHAR) Question: How many museums were opened after 2013 or before 2008? [/INST] SELECT COUNT(*) FROM museum WHERE open_year > 2013 OR open_year < 2008 </s>
Find the total number of players.
CREATE TABLE players (Id VARCHAR)
SELECT COUNT(*) FROM players
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE players (Id VARCHAR) Question: Find the total number of players. [/INST] SELECT COUNT(*) FROM players </s>
Find the total number of matches.
CREATE TABLE matches (Id VARCHAR)
SELECT COUNT(*) FROM matches
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE matches (Id VARCHAR) Question: Find the total number of matches. [/INST] SELECT COUNT(*) FROM matches </s>
List the first name and birth date of all players from the country with code USA.
CREATE TABLE players (first_name VARCHAR, birth_date VARCHAR, country_code VARCHAR)
SELECT first_name, birth_date FROM players WHERE country_code = 'USA'
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE players (first_name VARCHAR, birth_date VARCHAR, country_code VARCHAR) Question: List the first name and birth date of all players from the country with code USA. [/INST] SELECT first_name, birth_date FROM players WHERE country_code = 'USA' </s>
Find the average age of losers and winners of all matches.
CREATE TABLE matches (loser_age INTEGER, winner_age INTEGER)
SELECT AVG(loser_age), AVG(winner_age) FROM matches
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE matches (loser_age INTEGER, winner_age INTEGER) Question: Find the average age of losers and winners of all matches. [/INST] SELECT AVG(loser_age), AVG(winner_age) FROM matches </s>
Find the average rank of winners in all matches.
CREATE TABLE matches (winner_rank INTEGER)
SELECT AVG(winner_rank) FROM matches
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE matches (winner_rank INTEGER) Question: Find the average rank of winners in all matches. [/INST] SELECT AVG(winner_rank) FROM matches </s>
Find the highest rank of losers in all matches.
CREATE TABLE matches (loser_rank INTEGER)
SELECT MIN(loser_rank) FROM matches
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE matches (loser_rank INTEGER) Question: Find the highest rank of losers in all matches. [/INST] SELECT MIN(loser_rank) FROM matches </s>
find the number of distinct country codes of all players.
CREATE TABLE players (country_code VARCHAR)
SELECT COUNT(DISTINCT country_code) FROM players
<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 distinct country codes of all players. [/INST] SELECT COUNT(DISTINCT country_code) FROM players </s>
Find the number of distinct name of losers.
CREATE TABLE matches (loser_name VARCHAR)
SELECT COUNT(DISTINCT loser_name) FROM matches
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE matches (loser_name VARCHAR) Question: Find the number of distinct name of losers. [/INST] SELECT COUNT(DISTINCT loser_name) FROM matches </s>