instruction
stringlengths 12
244
| input
stringlengths 27
489
| output
stringlengths 18
557
| text
stringlengths 194
1.14k
|
---|---|---|---|
Find all the name of documents without any sections. | CREATE TABLE document_sections (document_name VARCHAR, document_code VARCHAR); CREATE TABLE documents (document_name VARCHAR, document_code VARCHAR) | SELECT document_name FROM documents WHERE NOT document_code IN (SELECT document_code FROM document_sections) | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE document_sections (document_name VARCHAR, document_code VARCHAR); CREATE TABLE documents (document_name VARCHAR, document_code VARCHAR) Question: Find all the name of documents without any sections. [/INST] SELECT document_name FROM documents WHERE NOT document_code IN (SELECT document_code FROM document_sections) </s> |
List all the username and passwords of users with the most popular role. | CREATE TABLE users (user_name VARCHAR, password VARCHAR, role_code VARCHAR) | SELECT TOP 1 user_name, password FROM users GROUP BY role_code ORDER BY COUNT(*) DESC | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE users (user_name VARCHAR, password VARCHAR, role_code VARCHAR) Question: List all the username and passwords of users with the most popular role. [/INST] SELECT TOP 1 user_name, password FROM users GROUP BY role_code ORDER BY COUNT(*) DESC </s> |
Find the average access counts of documents with functional area "Acknowledgement". | CREATE TABLE document_functional_areas (document_code VARCHAR, functional_area_code VARCHAR); CREATE TABLE documents (access_count INTEGER, document_code VARCHAR); CREATE TABLE functional_areas (functional_area_code VARCHAR, functional_area_description VARCHAR) | SELECT AVG(t1.access_count) FROM documents AS t1 JOIN document_functional_areas AS t2 ON t1.document_code = t2.document_code JOIN functional_areas AS t3 ON t2.functional_area_code = t3.functional_area_code WHERE t3.functional_area_description = "Acknowledgement" | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE document_functional_areas (document_code VARCHAR, functional_area_code VARCHAR); CREATE TABLE documents (access_count INTEGER, document_code VARCHAR); CREATE TABLE functional_areas (functional_area_code VARCHAR, functional_area_description VARCHAR) Question: Find the average access counts of documents with functional area "Acknowledgement". [/INST] SELECT AVG(t1.access_count) FROM documents AS t1 JOIN document_functional_areas AS t2 ON t1.document_code = t2.document_code JOIN functional_areas AS t3 ON t2.functional_area_code = t3.functional_area_code WHERE t3.functional_area_description = "Acknowledgement" </s> |
Find names of the document without any images. | CREATE TABLE document_sections_images (section_id VARCHAR); CREATE TABLE documents (document_name VARCHAR); CREATE TABLE documents (document_name VARCHAR, document_code VARCHAR); CREATE TABLE document_sections (document_code VARCHAR, section_id VARCHAR) | SELECT document_name FROM documents EXCEPT SELECT t1.document_name FROM documents AS t1 JOIN document_sections AS t2 ON t1.document_code = t2.document_code JOIN document_sections_images AS t3 ON t2.section_id = t3.section_id | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE document_sections_images (section_id VARCHAR); CREATE TABLE documents (document_name VARCHAR); CREATE TABLE documents (document_name VARCHAR, document_code VARCHAR); CREATE TABLE document_sections (document_code VARCHAR, section_id VARCHAR) Question: Find names of the document without any images. [/INST] SELECT document_name FROM documents EXCEPT SELECT t1.document_name FROM documents AS t1 JOIN document_sections AS t2 ON t1.document_code = t2.document_code JOIN document_sections_images AS t3 ON t2.section_id = t3.section_id </s> |
What is the name of the document with the most number of sections? | CREATE TABLE document_sections (document_code VARCHAR); CREATE TABLE documents (document_name VARCHAR, document_code VARCHAR) | SELECT TOP 1 t1.document_name FROM documents AS t1 JOIN document_sections AS t2 ON t1.document_code = t2.document_code GROUP BY t1.document_code ORDER BY COUNT(*) DESC | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE document_sections (document_code VARCHAR); CREATE TABLE documents (document_name VARCHAR, document_code VARCHAR) Question: What is the name of the document with the most number of sections? [/INST] SELECT TOP 1 t1.document_name FROM documents AS t1 JOIN document_sections AS t2 ON t1.document_code = t2.document_code GROUP BY t1.document_code ORDER BY COUNT(*) DESC </s> |
List all the document names which contains "CV". | CREATE TABLE documents (document_name VARCHAR) | SELECT document_name FROM documents WHERE document_name LIKE "%CV%" | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE documents (document_name VARCHAR) Question: List all the document names which contains "CV". [/INST] SELECT document_name FROM documents WHERE document_name LIKE "%CV%" </s> |
How many users are logged in? | CREATE TABLE users (user_login VARCHAR) | SELECT COUNT(*) FROM users WHERE user_login = 1 | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE users (user_login VARCHAR) Question: How many users are logged in? [/INST] SELECT COUNT(*) FROM users WHERE user_login = 1 </s> |
Find the description of the most popular role among the users that have logged in. | CREATE TABLE users (role_description VARCHAR, role_code VARCHAR, user_login VARCHAR); CREATE TABLE ROLES (role_description VARCHAR, role_code VARCHAR, user_login VARCHAR) | SELECT role_description FROM ROLES WHERE role_code = (SELECT TOP 1 role_code FROM users WHERE user_login = 1 GROUP BY role_code ORDER BY COUNT(*) DESC) | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE users (role_description VARCHAR, role_code VARCHAR, user_login VARCHAR); CREATE TABLE ROLES (role_description VARCHAR, role_code VARCHAR, user_login VARCHAR) Question: Find the description of the most popular role among the users that have logged in. [/INST] SELECT role_description FROM ROLES WHERE role_code = (SELECT TOP 1 role_code FROM users WHERE user_login = 1 GROUP BY role_code ORDER BY COUNT(*) DESC) </s> |
Find the average access count of documents with the least popular structure. | CREATE TABLE documents (access_count INTEGER, document_structure_code VARCHAR) | SELECT TOP 1 AVG(access_count) FROM documents GROUP BY document_structure_code ORDER BY COUNT(*) | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE documents (access_count INTEGER, document_structure_code VARCHAR) Question: Find the average access count of documents with the least popular structure. [/INST] SELECT TOP 1 AVG(access_count) FROM documents GROUP BY document_structure_code ORDER BY COUNT(*) </s> |
List all the image name and URLs in the order of their names. | CREATE TABLE images (image_name VARCHAR, image_url VARCHAR) | SELECT image_name, image_url FROM images ORDER BY image_name | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE images (image_name VARCHAR, image_url VARCHAR) Question: List all the image name and URLs in the order of their names. [/INST] SELECT image_name, image_url FROM images ORDER BY image_name </s> |
Find the number of users in each role. | CREATE TABLE users (role_code VARCHAR) | SELECT COUNT(*), role_code FROM users GROUP BY role_code | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE users (role_code VARCHAR) Question: Find the number of users in each role. [/INST] SELECT COUNT(*), role_code FROM users GROUP BY role_code </s> |
What document types have more than 2 corresponding documents? | CREATE TABLE documents (document_type_code VARCHAR) | SELECT document_type_code FROM documents GROUP BY document_type_code HAVING COUNT(*) > 2 | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE documents (document_type_code VARCHAR) Question: What document types have more than 2 corresponding documents? [/INST] SELECT document_type_code FROM documents GROUP BY document_type_code HAVING COUNT(*) > 2 </s> |
How many companies are there? | CREATE TABLE Companies (Id VARCHAR) | SELECT COUNT(*) FROM Companies | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Companies (Id VARCHAR) Question: How many companies are there? [/INST] SELECT COUNT(*) FROM Companies </s> |
List the names of companies in descending order of market value. | CREATE TABLE Companies (name VARCHAR, Market_Value_billion VARCHAR) | SELECT name FROM Companies ORDER BY Market_Value_billion DESC | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Companies (name VARCHAR, Market_Value_billion VARCHAR) Question: List the names of companies in descending order of market value. [/INST] SELECT name FROM Companies ORDER BY Market_Value_billion DESC </s> |
What are the names of companies whose headquarters are not "USA"? | CREATE TABLE Companies (name VARCHAR, Headquarters VARCHAR) | SELECT name FROM Companies WHERE Headquarters <> 'USA' | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Companies (name VARCHAR, Headquarters VARCHAR) Question: What are the names of companies whose headquarters are not "USA"? [/INST] SELECT name FROM Companies WHERE Headquarters <> 'USA' </s> |
What are the name and assets of each company, sorted in ascending order of company name? | CREATE TABLE Companies (name VARCHAR, Assets_billion VARCHAR) | SELECT name, Assets_billion FROM Companies ORDER BY name | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Companies (name VARCHAR, Assets_billion VARCHAR) Question: What are the name and assets of each company, sorted in ascending order of company name? [/INST] SELECT name, Assets_billion FROM Companies ORDER BY name </s> |
What are the average profits of companies? | CREATE TABLE Companies (Profits_billion INTEGER) | SELECT AVG(Profits_billion) FROM Companies | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Companies (Profits_billion INTEGER) Question: What are the average profits of companies? [/INST] SELECT AVG(Profits_billion) FROM Companies </s> |
What are the maximum and minimum sales of the companies whose industries are not "Banking". | CREATE TABLE Companies (Sales_billion INTEGER, Industry VARCHAR) | SELECT MAX(Sales_billion), MIN(Sales_billion) FROM Companies WHERE Industry <> "Banking" | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Companies (Sales_billion INTEGER, Industry VARCHAR) Question: What are the maximum and minimum sales of the companies whose industries are not "Banking". [/INST] SELECT MAX(Sales_billion), MIN(Sales_billion) FROM Companies WHERE Industry <> "Banking" </s> |
How many different industries are the companies in? | CREATE TABLE Companies (Industry VARCHAR) | SELECT COUNT(DISTINCT Industry) FROM Companies | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Companies (Industry VARCHAR) Question: How many different industries are the companies in? [/INST] SELECT COUNT(DISTINCT Industry) FROM Companies </s> |
List the names of buildings in descending order of building height. | CREATE TABLE buildings (name VARCHAR, Height VARCHAR) | SELECT name FROM buildings ORDER BY Height DESC | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE buildings (name VARCHAR, Height VARCHAR) Question: List the names of buildings in descending order of building height. [/INST] SELECT name FROM buildings ORDER BY Height DESC </s> |
Find the stories of the building with the largest height. | CREATE TABLE buildings (Stories VARCHAR, Height VARCHAR) | SELECT TOP 1 Stories FROM buildings ORDER BY Height DESC | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE buildings (Stories VARCHAR, Height VARCHAR) Question: Find the stories of the building with the largest height. [/INST] SELECT TOP 1 Stories FROM buildings ORDER BY Height DESC </s> |
List the name of a building along with the name of a company whose office is in the building. | CREATE TABLE buildings (name VARCHAR, id VARCHAR); CREATE TABLE Office_locations (building_id VARCHAR, company_id VARCHAR); CREATE TABLE Companies (name VARCHAR, id VARCHAR) | SELECT T3.name, T2.name FROM Office_locations AS T1 JOIN buildings AS T2 ON T1.building_id = T2.id JOIN Companies AS T3 ON T1.company_id = T3.id | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE buildings (name VARCHAR, id VARCHAR); CREATE TABLE Office_locations (building_id VARCHAR, company_id VARCHAR); CREATE TABLE Companies (name VARCHAR, id VARCHAR) Question: List the name of a building along with the name of a company whose office is in the building. [/INST] SELECT T3.name, T2.name FROM Office_locations AS T1 JOIN buildings AS T2 ON T1.building_id = T2.id JOIN Companies AS T3 ON T1.company_id = T3.id </s> |
Show the names of the buildings that have more than one company offices. | CREATE TABLE buildings (name VARCHAR, id VARCHAR); CREATE TABLE Companies (id VARCHAR); CREATE TABLE Office_locations (building_id VARCHAR, company_id VARCHAR) | SELECT T2.name FROM Office_locations AS T1 JOIN buildings AS T2 ON T1.building_id = T2.id JOIN Companies AS T3 ON T1.company_id = T3.id GROUP BY T1.building_id HAVING COUNT(*) > 1 | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE buildings (name VARCHAR, id VARCHAR); CREATE TABLE Companies (id VARCHAR); CREATE TABLE Office_locations (building_id VARCHAR, company_id VARCHAR) Question: Show the names of the buildings that have more than one company offices. [/INST] SELECT T2.name FROM Office_locations AS T1 JOIN buildings AS T2 ON T1.building_id = T2.id JOIN Companies AS T3 ON T1.company_id = T3.id GROUP BY T1.building_id HAVING COUNT(*) > 1 </s> |
Show the name of the building that has the most company offices. | CREATE TABLE buildings (name VARCHAR, id VARCHAR); CREATE TABLE Companies (id VARCHAR); CREATE TABLE Office_locations (building_id VARCHAR, company_id VARCHAR) | SELECT TOP 1 T2.name FROM Office_locations AS T1 JOIN buildings AS T2 ON T1.building_id = T2.id JOIN Companies AS T3 ON T1.company_id = T3.id GROUP BY T1.building_id ORDER BY COUNT(*) DESC | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE buildings (name VARCHAR, id VARCHAR); CREATE TABLE Companies (id VARCHAR); CREATE TABLE Office_locations (building_id VARCHAR, company_id VARCHAR) Question: Show the name of the building that has the most company offices. [/INST] SELECT TOP 1 T2.name FROM Office_locations AS T1 JOIN buildings AS T2 ON T1.building_id = T2.id JOIN Companies AS T3 ON T1.company_id = T3.id GROUP BY T1.building_id ORDER BY COUNT(*) DESC </s> |
Please show the names of the buildings whose status is "on-hold", in ascending order of stories. | CREATE TABLE buildings (name VARCHAR, Status VARCHAR, Stories VARCHAR) | SELECT name FROM buildings WHERE Status = "on-hold" ORDER BY Stories | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE buildings (name VARCHAR, Status VARCHAR, Stories VARCHAR) Question: Please show the names of the buildings whose status is "on-hold", in ascending order of stories. [/INST] SELECT name FROM buildings WHERE Status = "on-hold" ORDER BY Stories </s> |
Please show each industry and the corresponding number of companies in that industry. | CREATE TABLE Companies (Industry VARCHAR) | SELECT Industry, COUNT(*) FROM Companies GROUP BY Industry | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Companies (Industry VARCHAR) Question: Please show each industry and the corresponding number of companies in that industry. [/INST] SELECT Industry, COUNT(*) FROM Companies GROUP BY Industry </s> |
Please show the industries of companies in descending order of the number of companies. | CREATE TABLE Companies (Industry VARCHAR) | SELECT Industry FROM Companies GROUP BY Industry ORDER BY COUNT(*) DESC | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Companies (Industry VARCHAR) Question: Please show the industries of companies in descending order of the number of companies. [/INST] SELECT Industry FROM Companies GROUP BY Industry ORDER BY COUNT(*) DESC </s> |
List the industry shared by the most companies. | CREATE TABLE Companies (Industry VARCHAR) | SELECT TOP 1 Industry FROM Companies GROUP BY Industry ORDER BY COUNT(*) DESC | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Companies (Industry VARCHAR) Question: List the industry shared by the most companies. [/INST] SELECT TOP 1 Industry FROM Companies GROUP BY Industry ORDER BY COUNT(*) DESC </s> |
List the names of buildings that have no company office. | CREATE TABLE buildings (name VARCHAR, id VARCHAR, building_id VARCHAR); CREATE TABLE Office_locations (name VARCHAR, id VARCHAR, building_id VARCHAR) | SELECT name FROM buildings WHERE NOT id IN (SELECT building_id FROM Office_locations) | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE buildings (name VARCHAR, id VARCHAR, building_id VARCHAR); CREATE TABLE Office_locations (name VARCHAR, id VARCHAR, building_id VARCHAR) Question: List the names of buildings that have no company office. [/INST] SELECT name FROM buildings WHERE NOT id IN (SELECT building_id FROM Office_locations) </s> |
Show the industries shared by companies whose headquarters are "USA" and companies whose headquarters are "China". | CREATE TABLE Companies (Industry VARCHAR, Headquarters VARCHAR) | SELECT Industry FROM Companies WHERE Headquarters = "USA" INTERSECT SELECT Industry FROM Companies WHERE Headquarters = "China" | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Companies (Industry VARCHAR, Headquarters VARCHAR) Question: Show the industries shared by companies whose headquarters are "USA" and companies whose headquarters are "China". [/INST] SELECT Industry FROM Companies WHERE Headquarters = "USA" INTERSECT SELECT Industry FROM Companies WHERE Headquarters = "China" </s> |
Find the number of companies whose industry is "Banking" or "Conglomerate", | CREATE TABLE Companies (Industry VARCHAR) | SELECT COUNT(*) FROM Companies WHERE Industry = "Banking" OR Industry = "Conglomerate" | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Companies (Industry VARCHAR) Question: Find the number of companies whose industry is "Banking" or "Conglomerate", [/INST] SELECT COUNT(*) FROM Companies WHERE Industry = "Banking" OR Industry = "Conglomerate" </s> |
Show the headquarters shared by more than two companies. | CREATE TABLE Companies (Headquarters VARCHAR) | SELECT Headquarters FROM Companies GROUP BY Headquarters HAVING COUNT(*) > 2 | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Companies (Headquarters VARCHAR) Question: Show the headquarters shared by more than two companies. [/INST] SELECT Headquarters FROM Companies GROUP BY Headquarters HAVING COUNT(*) > 2 </s> |
How many products are there? | CREATE TABLE Products (Id VARCHAR) | SELECT COUNT(*) FROM Products | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Products (Id VARCHAR) Question: How many products are there? [/INST] SELECT COUNT(*) FROM Products </s> |
List the name of products in ascending order of price. | CREATE TABLE Products (Product_Name VARCHAR, Product_Price VARCHAR) | SELECT Product_Name FROM Products ORDER BY Product_Price | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Products (Product_Name VARCHAR, Product_Price VARCHAR) Question: List the name of products in ascending order of price. [/INST] SELECT Product_Name FROM Products ORDER BY Product_Price </s> |
What are the names and type codes of products? | CREATE TABLE Products (Product_Name VARCHAR, Product_Type_Code VARCHAR) | SELECT Product_Name, Product_Type_Code FROM Products | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Products (Product_Name VARCHAR, Product_Type_Code VARCHAR) Question: What are the names and type codes of products? [/INST] SELECT Product_Name, Product_Type_Code FROM Products </s> |
Show the prices of the products named "Dining" or "Trading Policy". | CREATE TABLE Products (Product_Price VARCHAR, Product_Name VARCHAR) | SELECT Product_Price FROM Products WHERE Product_Name = "Dining" OR Product_Name = "Trading Policy" | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Products (Product_Price VARCHAR, Product_Name VARCHAR) Question: Show the prices of the products named "Dining" or "Trading Policy". [/INST] SELECT Product_Price FROM Products WHERE Product_Name = "Dining" OR Product_Name = "Trading Policy" </s> |
What is the average price for products? | CREATE TABLE Products (Product_Price INTEGER) | SELECT AVG(Product_Price) FROM Products | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Products (Product_Price INTEGER) Question: What is the average price for products? [/INST] SELECT AVG(Product_Price) FROM Products </s> |
What is the name of the product with the highest price? | CREATE TABLE Products (Product_Name VARCHAR, Product_Price VARCHAR) | SELECT TOP 1 Product_Name FROM Products ORDER BY Product_Price DESC | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Products (Product_Name VARCHAR, Product_Price VARCHAR) Question: What is the name of the product with the highest price? [/INST] SELECT TOP 1 Product_Name FROM Products ORDER BY Product_Price DESC </s> |
Show different type codes of products and the number of products with each type code. | CREATE TABLE Products (Product_Type_Code VARCHAR) | SELECT Product_Type_Code, COUNT(*) FROM Products GROUP BY Product_Type_Code | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Products (Product_Type_Code VARCHAR) Question: Show different type codes of products and the number of products with each type code. [/INST] SELECT Product_Type_Code, COUNT(*) FROM Products GROUP BY Product_Type_Code </s> |
Show the most common type code across products. | CREATE TABLE Products (Product_Type_Code VARCHAR) | SELECT TOP 1 Product_Type_Code FROM Products GROUP BY Product_Type_Code ORDER BY COUNT(*) DESC | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Products (Product_Type_Code VARCHAR) Question: Show the most common type code across products. [/INST] SELECT TOP 1 Product_Type_Code FROM Products GROUP BY Product_Type_Code ORDER BY COUNT(*) DESC </s> |
Show the product type codes that have at least two products. | CREATE TABLE Products (Product_Type_Code VARCHAR) | SELECT Product_Type_Code FROM Products GROUP BY Product_Type_Code HAVING COUNT(*) >= 2 | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Products (Product_Type_Code VARCHAR) Question: Show the product type codes that have at least two products. [/INST] SELECT Product_Type_Code FROM Products GROUP BY Product_Type_Code HAVING COUNT(*) >= 2 </s> |
Show the product type codes that have both products with price higher than 4500 and products with price lower than 3000. | CREATE TABLE Products (Product_Type_Code VARCHAR, Product_Price INTEGER) | SELECT Product_Type_Code FROM Products WHERE Product_Price > 4500 INTERSECT SELECT Product_Type_Code FROM Products WHERE Product_Price < 3000 | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Products (Product_Type_Code VARCHAR, Product_Price INTEGER) Question: Show the product type codes that have both products with price higher than 4500 and products with price lower than 3000. [/INST] SELECT Product_Type_Code FROM Products WHERE Product_Price > 4500 INTERSECT SELECT Product_Type_Code FROM Products WHERE Product_Price < 3000 </s> |
Show the names of products and the number of events they are in. | CREATE TABLE Products (Product_Name VARCHAR, Product_ID VARCHAR); CREATE TABLE Products_in_Events (Product_ID VARCHAR) | SELECT T1.Product_Name, COUNT(*) FROM Products AS T1 JOIN Products_in_Events AS T2 ON T1.Product_ID = T2.Product_ID GROUP BY T1.Product_Name | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Products (Product_Name VARCHAR, Product_ID VARCHAR); CREATE TABLE Products_in_Events (Product_ID VARCHAR) Question: Show the names of products and the number of events they are in. [/INST] SELECT T1.Product_Name, COUNT(*) FROM Products AS T1 JOIN Products_in_Events AS T2 ON T1.Product_ID = T2.Product_ID GROUP BY T1.Product_Name </s> |
Show the names of products and the number of events they are in, sorted by the number of events in descending order. | CREATE TABLE Products (Product_Name VARCHAR, Product_ID VARCHAR); CREATE TABLE Products_in_Events (Product_ID VARCHAR) | SELECT T1.Product_Name, COUNT(*) FROM Products AS T1 JOIN Products_in_Events 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 Products (Product_Name VARCHAR, Product_ID VARCHAR); CREATE TABLE Products_in_Events (Product_ID VARCHAR) Question: Show the names of products and the number of events they are in, sorted by the number of events in descending order. [/INST] SELECT T1.Product_Name, COUNT(*) FROM Products AS T1 JOIN Products_in_Events AS T2 ON T1.Product_ID = T2.Product_ID GROUP BY T1.Product_Name ORDER BY COUNT(*) DESC </s> |
Show the names of products that are in at least two events. | CREATE TABLE Products (Product_Name VARCHAR, Product_ID VARCHAR); CREATE TABLE Products_in_Events (Product_ID VARCHAR) | SELECT T1.Product_Name FROM Products AS T1 JOIN Products_in_Events AS T2 ON T1.Product_ID = T2.Product_ID GROUP BY T1.Product_Name HAVING COUNT(*) >= 2 | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Products (Product_Name VARCHAR, Product_ID VARCHAR); CREATE TABLE Products_in_Events (Product_ID VARCHAR) Question: Show the names of products that are in at least two events. [/INST] SELECT T1.Product_Name FROM Products AS T1 JOIN Products_in_Events AS T2 ON T1.Product_ID = T2.Product_ID GROUP BY T1.Product_Name HAVING COUNT(*) >= 2 </s> |
Show the names of products that are in at least two events in ascending alphabetical order of product name. | CREATE TABLE Products (Product_Name VARCHAR, Product_ID VARCHAR); CREATE TABLE Products_in_Events (Product_ID VARCHAR) | SELECT T1.Product_Name FROM Products AS T1 JOIN Products_in_Events AS T2 ON T1.Product_ID = T2.Product_ID GROUP BY T1.Product_Name HAVING COUNT(*) >= 2 ORDER BY T1.Product_Name | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Products (Product_Name VARCHAR, Product_ID VARCHAR); CREATE TABLE Products_in_Events (Product_ID VARCHAR) Question: Show the names of products that are in at least two events in ascending alphabetical order of product name. [/INST] SELECT T1.Product_Name FROM Products AS T1 JOIN Products_in_Events AS T2 ON T1.Product_ID = T2.Product_ID GROUP BY T1.Product_Name HAVING COUNT(*) >= 2 ORDER BY T1.Product_Name </s> |
List the names of products that are not in any event. | CREATE TABLE Products (Product_Name VARCHAR, Product_ID VARCHAR); CREATE TABLE Products_in_Events (Product_Name VARCHAR, Product_ID VARCHAR) | SELECT Product_Name FROM Products WHERE NOT Product_ID IN (SELECT Product_ID FROM Products_in_Events) | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE Products (Product_Name VARCHAR, Product_ID VARCHAR); CREATE TABLE Products_in_Events (Product_Name VARCHAR, Product_ID VARCHAR) Question: List the names of products that are not in any event. [/INST] SELECT Product_Name FROM Products WHERE NOT Product_ID IN (SELECT Product_ID FROM Products_in_Events) </s> |
How many artworks are there? | CREATE TABLE artwork (Id VARCHAR) | SELECT COUNT(*) FROM artwork | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE artwork (Id VARCHAR) Question: How many artworks are there? [/INST] SELECT COUNT(*) FROM artwork </s> |
List the name of artworks in ascending alphabetical order. | CREATE TABLE artwork (Name VARCHAR) | SELECT Name FROM artwork ORDER BY Name | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE artwork (Name VARCHAR) Question: List the name of artworks in ascending alphabetical order. [/INST] SELECT Name FROM artwork ORDER BY Name </s> |
List the name of artworks whose type is not "Program Talent Show". | CREATE TABLE artwork (Name VARCHAR, TYPE VARCHAR) | SELECT Name FROM artwork WHERE TYPE <> "Program Talent Show" | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE artwork (Name VARCHAR, TYPE VARCHAR) Question: List the name of artworks whose type is not "Program Talent Show". [/INST] SELECT Name FROM artwork WHERE TYPE <> "Program Talent Show" </s> |
What are the names and locations of festivals? | CREATE TABLE festival_detail (Festival_Name VARCHAR, LOCATION VARCHAR) | SELECT Festival_Name, LOCATION FROM festival_detail | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE festival_detail (Festival_Name VARCHAR, LOCATION VARCHAR) Question: What are the names and locations of festivals? [/INST] SELECT Festival_Name, LOCATION FROM festival_detail </s> |
What are the names of the chairs of festivals, sorted in ascending order of the year held? | CREATE TABLE festival_detail (Chair_Name VARCHAR, YEAR VARCHAR) | SELECT Chair_Name FROM festival_detail ORDER BY YEAR | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE festival_detail (Chair_Name VARCHAR, YEAR VARCHAR) Question: What are the names of the chairs of festivals, sorted in ascending order of the year held? [/INST] SELECT Chair_Name FROM festival_detail ORDER BY YEAR </s> |
What is the location of the festival with the largest number of audience? | CREATE TABLE festival_detail (LOCATION VARCHAR, Num_of_Audience VARCHAR) | SELECT TOP 1 LOCATION FROM festival_detail ORDER BY Num_of_Audience DESC | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE festival_detail (LOCATION VARCHAR, Num_of_Audience VARCHAR) Question: What is the location of the festival with the largest number of audience? [/INST] SELECT TOP 1 LOCATION FROM festival_detail ORDER BY Num_of_Audience DESC </s> |
What are the names of festivals held in year 2007? | CREATE TABLE festival_detail (Festival_Name VARCHAR, YEAR VARCHAR) | SELECT Festival_Name FROM festival_detail WHERE YEAR = 2007 | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE festival_detail (Festival_Name VARCHAR, YEAR VARCHAR) Question: What are the names of festivals held in year 2007? [/INST] SELECT Festival_Name FROM festival_detail WHERE YEAR = 2007 </s> |
What is the average number of audience for festivals? | CREATE TABLE festival_detail (Num_of_Audience INTEGER) | SELECT AVG(Num_of_Audience) FROM festival_detail | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE festival_detail (Num_of_Audience INTEGER) Question: What is the average number of audience for festivals? [/INST] SELECT AVG(Num_of_Audience) FROM festival_detail </s> |
Show the names of the three most recent festivals. | CREATE TABLE festival_detail (Festival_Name VARCHAR, YEAR VARCHAR) | SELECT TOP 3 Festival_Name FROM festival_detail ORDER BY YEAR DESC | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE festival_detail (Festival_Name VARCHAR, YEAR VARCHAR) Question: Show the names of the three most recent festivals. [/INST] SELECT TOP 3 Festival_Name FROM festival_detail ORDER BY YEAR DESC </s> |
For each nomination, show the name of the artwork and name of the festival where it is nominated. | CREATE TABLE artwork (Name VARCHAR, Artwork_ID VARCHAR); CREATE TABLE nomination (Artwork_ID VARCHAR, Festival_ID VARCHAR); CREATE TABLE festival_detail (Festival_Name VARCHAR, Festival_ID VARCHAR) | SELECT T2.Name, T3.Festival_Name FROM nomination AS T1 JOIN artwork AS T2 ON T1.Artwork_ID = T2.Artwork_ID JOIN festival_detail AS T3 ON T1.Festival_ID = T3.Festival_ID | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE artwork (Name VARCHAR, Artwork_ID VARCHAR); CREATE TABLE nomination (Artwork_ID VARCHAR, Festival_ID VARCHAR); CREATE TABLE festival_detail (Festival_Name VARCHAR, Festival_ID VARCHAR) Question: For each nomination, show the name of the artwork and name of the festival where it is nominated. [/INST] SELECT T2.Name, T3.Festival_Name FROM nomination AS T1 JOIN artwork AS T2 ON T1.Artwork_ID = T2.Artwork_ID JOIN festival_detail AS T3 ON T1.Festival_ID = T3.Festival_ID </s> |
Show distinct types of artworks that are nominated in festivals in 2007. | CREATE TABLE nomination (Artwork_ID VARCHAR, Festival_ID VARCHAR); CREATE TABLE festival_detail (Festival_ID VARCHAR, Year VARCHAR); CREATE TABLE artwork (Type VARCHAR, Artwork_ID VARCHAR) | SELECT DISTINCT T2.Type FROM nomination AS T1 JOIN artwork AS T2 ON T1.Artwork_ID = T2.Artwork_ID JOIN festival_detail AS T3 ON T1.Festival_ID = T3.Festival_ID WHERE T3.Year = 2007 | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE nomination (Artwork_ID VARCHAR, Festival_ID VARCHAR); CREATE TABLE festival_detail (Festival_ID VARCHAR, Year VARCHAR); CREATE TABLE artwork (Type VARCHAR, Artwork_ID VARCHAR) Question: Show distinct types of artworks that are nominated in festivals in 2007. [/INST] SELECT DISTINCT T2.Type FROM nomination AS T1 JOIN artwork AS T2 ON T1.Artwork_ID = T2.Artwork_ID JOIN festival_detail AS T3 ON T1.Festival_ID = T3.Festival_ID WHERE T3.Year = 2007 </s> |
Show the names of artworks in ascending order of the year they are nominated in. | CREATE TABLE artwork (Name VARCHAR, Artwork_ID VARCHAR); CREATE TABLE nomination (Artwork_ID VARCHAR, Festival_ID VARCHAR); CREATE TABLE festival_detail (Festival_ID VARCHAR, Year VARCHAR) | SELECT T2.Name FROM nomination AS T1 JOIN artwork AS T2 ON T1.Artwork_ID = T2.Artwork_ID JOIN festival_detail AS T3 ON T1.Festival_ID = T3.Festival_ID ORDER BY T3.Year | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE artwork (Name VARCHAR, Artwork_ID VARCHAR); CREATE TABLE nomination (Artwork_ID VARCHAR, Festival_ID VARCHAR); CREATE TABLE festival_detail (Festival_ID VARCHAR, Year VARCHAR) Question: Show the names of artworks in ascending order of the year they are nominated in. [/INST] SELECT T2.Name FROM nomination AS T1 JOIN artwork AS T2 ON T1.Artwork_ID = T2.Artwork_ID JOIN festival_detail AS T3 ON T1.Festival_ID = T3.Festival_ID ORDER BY T3.Year </s> |
Show the names of festivals that have nominated artworks of type "Program Talent Show". | CREATE TABLE nomination (Artwork_ID VARCHAR, Festival_ID VARCHAR); CREATE TABLE artwork (Artwork_ID VARCHAR, Type VARCHAR); CREATE TABLE festival_detail (Festival_Name VARCHAR, Festival_ID VARCHAR) | SELECT T3.Festival_Name FROM nomination AS T1 JOIN artwork AS T2 ON T1.Artwork_ID = T2.Artwork_ID JOIN festival_detail AS T3 ON T1.Festival_ID = T3.Festival_ID WHERE T2.Type = "Program Talent Show" | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE nomination (Artwork_ID VARCHAR, Festival_ID VARCHAR); CREATE TABLE artwork (Artwork_ID VARCHAR, Type VARCHAR); CREATE TABLE festival_detail (Festival_Name VARCHAR, Festival_ID VARCHAR) Question: Show the names of festivals that have nominated artworks of type "Program Talent Show". [/INST] SELECT T3.Festival_Name FROM nomination AS T1 JOIN artwork AS T2 ON T1.Artwork_ID = T2.Artwork_ID JOIN festival_detail AS T3 ON T1.Festival_ID = T3.Festival_ID WHERE T2.Type = "Program Talent Show" </s> |
Show the ids and names of festivals that have at least two nominations for artworks. | CREATE TABLE nomination (Festival_ID VARCHAR, Artwork_ID VARCHAR); CREATE TABLE festival_detail (Festival_Name VARCHAR, Festival_ID VARCHAR); CREATE TABLE artwork (Artwork_ID VARCHAR) | SELECT T1.Festival_ID, T3.Festival_Name FROM nomination AS T1 JOIN artwork AS T2 ON T1.Artwork_ID = T2.Artwork_ID JOIN festival_detail AS T3 ON T1.Festival_ID = T3.Festival_ID GROUP BY T1.Festival_ID HAVING COUNT(*) >= 2 | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE nomination (Festival_ID VARCHAR, Artwork_ID VARCHAR); CREATE TABLE festival_detail (Festival_Name VARCHAR, Festival_ID VARCHAR); CREATE TABLE artwork (Artwork_ID VARCHAR) Question: Show the ids and names of festivals that have at least two nominations for artworks. [/INST] SELECT T1.Festival_ID, T3.Festival_Name FROM nomination AS T1 JOIN artwork AS T2 ON T1.Artwork_ID = T2.Artwork_ID JOIN festival_detail AS T3 ON T1.Festival_ID = T3.Festival_ID GROUP BY T1.Festival_ID HAVING COUNT(*) >= 2 </s> |
Show the id, name of each festival and the number of artworks it has nominated. | CREATE TABLE nomination (Festival_ID VARCHAR, Artwork_ID VARCHAR); CREATE TABLE festival_detail (Festival_Name VARCHAR, Festival_ID VARCHAR); CREATE TABLE artwork (Artwork_ID VARCHAR) | SELECT T1.Festival_ID, T3.Festival_Name, COUNT(*) FROM nomination AS T1 JOIN artwork AS T2 ON T1.Artwork_ID = T2.Artwork_ID JOIN festival_detail AS T3 ON T1.Festival_ID = T3.Festival_ID GROUP BY T1.Festival_ID | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE nomination (Festival_ID VARCHAR, Artwork_ID VARCHAR); CREATE TABLE festival_detail (Festival_Name VARCHAR, Festival_ID VARCHAR); CREATE TABLE artwork (Artwork_ID VARCHAR) Question: Show the id, name of each festival and the number of artworks it has nominated. [/INST] SELECT T1.Festival_ID, T3.Festival_Name, COUNT(*) FROM nomination AS T1 JOIN artwork AS T2 ON T1.Artwork_ID = T2.Artwork_ID JOIN festival_detail AS T3 ON T1.Festival_ID = T3.Festival_ID GROUP BY T1.Festival_ID </s> |
Please show different types of artworks with the corresponding number of artworks of each type. | CREATE TABLE artwork (TYPE VARCHAR) | SELECT TYPE, COUNT(*) FROM artwork GROUP BY TYPE | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE artwork (TYPE VARCHAR) Question: Please show different types of artworks with the corresponding number of artworks of each type. [/INST] SELECT TYPE, COUNT(*) FROM artwork GROUP BY TYPE </s> |
List the most common type of artworks. | CREATE TABLE artwork (TYPE VARCHAR) | SELECT TOP 1 TYPE FROM artwork GROUP BY TYPE ORDER BY COUNT(*) DESC | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE artwork (TYPE VARCHAR) Question: List the most common type of artworks. [/INST] SELECT TOP 1 TYPE FROM artwork GROUP BY TYPE ORDER BY COUNT(*) DESC </s> |
List the year in which there are more than one festivals. | CREATE TABLE festival_detail (YEAR VARCHAR) | SELECT YEAR FROM festival_detail GROUP BY YEAR HAVING COUNT(*) > 1 | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE festival_detail (YEAR VARCHAR) Question: List the year in which there are more than one festivals. [/INST] SELECT YEAR FROM festival_detail GROUP BY YEAR HAVING COUNT(*) > 1 </s> |
List the name of artworks that are not nominated. | CREATE TABLE nomination (Name VARCHAR, Artwork_ID VARCHAR); CREATE TABLE Artwork (Name VARCHAR, Artwork_ID VARCHAR) | SELECT Name FROM Artwork WHERE NOT Artwork_ID IN (SELECT Artwork_ID FROM nomination) | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE nomination (Name VARCHAR, Artwork_ID VARCHAR); CREATE TABLE Artwork (Name VARCHAR, Artwork_ID VARCHAR) Question: List the name of artworks that are not nominated. [/INST] SELECT Name FROM Artwork WHERE NOT Artwork_ID IN (SELECT Artwork_ID FROM nomination) </s> |
Show the number of audience in year 2008 or 2010. | CREATE TABLE festival_detail (Num_of_Audience VARCHAR, YEAR VARCHAR) | SELECT Num_of_Audience FROM festival_detail WHERE YEAR = 2008 OR YEAR = 2010 | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE festival_detail (Num_of_Audience VARCHAR, YEAR VARCHAR) Question: Show the number of audience in year 2008 or 2010. [/INST] SELECT Num_of_Audience FROM festival_detail WHERE YEAR = 2008 OR YEAR = 2010 </s> |
What are the total number of the audiences who visited any of the festivals? | CREATE TABLE festival_detail (Num_of_Audience INTEGER) | SELECT SUM(Num_of_Audience) FROM festival_detail | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE festival_detail (Num_of_Audience INTEGER) Question: What are the total number of the audiences who visited any of the festivals? [/INST] SELECT SUM(Num_of_Audience) FROM festival_detail </s> |
In which year are there festivals both inside the 'United States' and outside the 'United States'? | CREATE TABLE festival_detail (YEAR VARCHAR, LOCATION VARCHAR) | SELECT YEAR FROM festival_detail WHERE LOCATION = 'United States' INTERSECT SELECT YEAR FROM festival_detail WHERE LOCATION <> 'United States' | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE festival_detail (YEAR VARCHAR, LOCATION VARCHAR) Question: In which year are there festivals both inside the 'United States' and outside the 'United States'? [/INST] SELECT YEAR FROM festival_detail WHERE LOCATION = 'United States' INTERSECT SELECT YEAR FROM festival_detail WHERE LOCATION <> 'United States' </s> |
How many premises are there? | CREATE TABLE premises (Id VARCHAR) | SELECT COUNT(*) FROM premises | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE premises (Id VARCHAR) Question: How many premises are there? [/INST] SELECT COUNT(*) FROM premises </s> |
What are all the distinct premise types? | CREATE TABLE premises (premises_type VARCHAR) | SELECT DISTINCT premises_type FROM premises | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE premises (premises_type VARCHAR) Question: What are all the distinct premise types? [/INST] SELECT DISTINCT premises_type FROM premises </s> |
Find the types and details for all premises and order by the premise type. | CREATE TABLE premises (premises_type VARCHAR, premise_details VARCHAR) | SELECT premises_type, premise_details FROM premises ORDER BY premises_type | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE premises (premises_type VARCHAR, premise_details VARCHAR) Question: Find the types and details for all premises and order by the premise type. [/INST] SELECT premises_type, premise_details FROM premises ORDER BY premises_type </s> |
Show each premise type and the number of premises in that type. | CREATE TABLE premises (premises_type VARCHAR) | SELECT premises_type, COUNT(*) FROM premises GROUP BY premises_type | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE premises (premises_type VARCHAR) Question: Show each premise type and the number of premises in that type. [/INST] SELECT premises_type, COUNT(*) FROM premises GROUP BY premises_type </s> |
Show all distinct product categories along with the number of mailshots in each category. | CREATE TABLE mailshot_campaigns (product_category VARCHAR) | SELECT product_category, COUNT(*) FROM mailshot_campaigns GROUP BY product_category | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE mailshot_campaigns (product_category VARCHAR) Question: Show all distinct product categories along with the number of mailshots in each category. [/INST] SELECT product_category, COUNT(*) FROM mailshot_campaigns GROUP BY product_category </s> |
Show the name and phone of the customer without any mailshot. | CREATE TABLE customers (customer_name VARCHAR, customer_phone VARCHAR, customer_id VARCHAR); CREATE TABLE mailshot_customers (customer_name VARCHAR, customer_phone VARCHAR, customer_id VARCHAR) | SELECT customer_name, customer_phone FROM customers WHERE NOT customer_id IN (SELECT customer_id FROM mailshot_customers) | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE customers (customer_name VARCHAR, customer_phone VARCHAR, customer_id VARCHAR); CREATE TABLE mailshot_customers (customer_name VARCHAR, customer_phone VARCHAR, customer_id VARCHAR) Question: Show the name and phone of the customer without any mailshot. [/INST] SELECT customer_name, customer_phone FROM customers WHERE NOT customer_id IN (SELECT customer_id FROM mailshot_customers) </s> |
Show the name and phone for customers with a mailshot with outcome code 'No Response'. | CREATE TABLE customers (customer_name VARCHAR, customer_phone VARCHAR, customer_id VARCHAR); CREATE TABLE mailshot_customers (customer_id VARCHAR, outcome_code VARCHAR) | SELECT T1.customer_name, T1.customer_phone FROM customers AS T1 JOIN mailshot_customers AS T2 ON T1.customer_id = T2.customer_id WHERE T2.outcome_code = 'No Response' | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE customers (customer_name VARCHAR, customer_phone VARCHAR, customer_id VARCHAR); CREATE TABLE mailshot_customers (customer_id VARCHAR, outcome_code VARCHAR) Question: Show the name and phone for customers with a mailshot with outcome code 'No Response'. [/INST] SELECT T1.customer_name, T1.customer_phone FROM customers AS T1 JOIN mailshot_customers AS T2 ON T1.customer_id = T2.customer_id WHERE T2.outcome_code = 'No Response' </s> |
Show the outcome code of mailshots along with the number of mailshots in each outcome code. | CREATE TABLE mailshot_customers (outcome_code VARCHAR) | SELECT outcome_code, COUNT(*) FROM mailshot_customers GROUP BY outcome_code | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE mailshot_customers (outcome_code VARCHAR) Question: Show the outcome code of mailshots along with the number of mailshots in each outcome code. [/INST] SELECT outcome_code, COUNT(*) FROM mailshot_customers GROUP BY outcome_code </s> |
Show the names of customers who have at least 2 mailshots with outcome code 'Order'. | CREATE TABLE customers (customer_name VARCHAR, customer_id VARCHAR); CREATE TABLE mailshot_customers (customer_id VARCHAR) | SELECT T2.customer_name FROM mailshot_customers AS T1 JOIN customers AS T2 ON T1.customer_id = T2.customer_id WHERE outcome_code = 'Order' GROUP BY T1.customer_id HAVING COUNT(*) >= 2 | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE customers (customer_name VARCHAR, customer_id VARCHAR); CREATE TABLE mailshot_customers (customer_id VARCHAR) Question: Show the names of customers who have at least 2 mailshots with outcome code 'Order'. [/INST] SELECT T2.customer_name FROM mailshot_customers AS T1 JOIN customers AS T2 ON T1.customer_id = T2.customer_id WHERE outcome_code = 'Order' GROUP BY T1.customer_id HAVING COUNT(*) >= 2 </s> |
Show the names of customers who have the most mailshots. | CREATE TABLE customers (customer_name VARCHAR, customer_id VARCHAR); CREATE TABLE mailshot_customers (customer_id VARCHAR) | SELECT TOP 1 T2.customer_name FROM mailshot_customers AS T1 JOIN customers AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id ORDER BY COUNT(*) DESC | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE customers (customer_name VARCHAR, customer_id VARCHAR); CREATE TABLE mailshot_customers (customer_id VARCHAR) Question: Show the names of customers who have the most mailshots. [/INST] SELECT TOP 1 T2.customer_name FROM mailshot_customers AS T1 JOIN customers AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id ORDER BY COUNT(*) DESC </s> |
What are the name and payment method of customers who have both mailshots in 'Order' outcome and mailshots in 'No Response' outcome. | CREATE TABLE customers (customer_name VARCHAR, payment_method VARCHAR, customer_id VARCHAR); CREATE TABLE mailshot_customers (customer_id VARCHAR, outcome_code VARCHAR) | SELECT T2.customer_name, T2.payment_method FROM mailshot_customers AS T1 JOIN customers AS T2 ON T1.customer_id = T2.customer_id WHERE T1.outcome_code = 'Order' INTERSECT SELECT T2.customer_name, T2.payment_method FROM mailshot_customers AS T1 JOIN customers AS T2 ON T1.customer_id = T2.customer_id WHERE T1.outcome_code = 'No Response' | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE customers (customer_name VARCHAR, payment_method VARCHAR, customer_id VARCHAR); CREATE TABLE mailshot_customers (customer_id VARCHAR, outcome_code VARCHAR) Question: What are the name and payment method of customers who have both mailshots in 'Order' outcome and mailshots in 'No Response' outcome. [/INST] SELECT T2.customer_name, T2.payment_method FROM mailshot_customers AS T1 JOIN customers AS T2 ON T1.customer_id = T2.customer_id WHERE T1.outcome_code = 'Order' INTERSECT SELECT T2.customer_name, T2.payment_method FROM mailshot_customers AS T1 JOIN customers AS T2 ON T1.customer_id = T2.customer_id WHERE T1.outcome_code = 'No Response' </s> |
Show the premise type and address type code for all customer addresses. | CREATE TABLE premises (premises_type VARCHAR, premise_id VARCHAR); CREATE TABLE customer_addresses (address_type_code VARCHAR, premise_id VARCHAR) | SELECT T2.premises_type, T1.address_type_code FROM customer_addresses AS T1 JOIN premises AS T2 ON T1.premise_id = T2.premise_id | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE premises (premises_type VARCHAR, premise_id VARCHAR); CREATE TABLE customer_addresses (address_type_code VARCHAR, premise_id VARCHAR) Question: Show the premise type and address type code for all customer addresses. [/INST] SELECT T2.premises_type, T1.address_type_code FROM customer_addresses AS T1 JOIN premises AS T2 ON T1.premise_id = T2.premise_id </s> |
What are the distinct address type codes for all customer addresses? | CREATE TABLE customer_addresses (address_type_code VARCHAR) | SELECT DISTINCT address_type_code FROM customer_addresses | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE customer_addresses (address_type_code VARCHAR) Question: What are the distinct address type codes for all customer addresses? [/INST] SELECT DISTINCT address_type_code FROM customer_addresses </s> |
Show the shipping charge and customer id for customer orders with order status Cancelled or Paid. | CREATE TABLE customer_orders (order_shipping_charges VARCHAR, customer_id VARCHAR, order_status_code VARCHAR) | SELECT order_shipping_charges, customer_id FROM customer_orders WHERE order_status_code = 'Cancelled' OR order_status_code = 'Paid' | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE customer_orders (order_shipping_charges VARCHAR, customer_id VARCHAR, order_status_code VARCHAR) Question: Show the shipping charge and customer id for customer orders with order status Cancelled or Paid. [/INST] SELECT order_shipping_charges, customer_id FROM customer_orders WHERE order_status_code = 'Cancelled' OR order_status_code = 'Paid' </s> |
Show the names of customers having an order with shipping method FedEx and order status Paid. | CREATE TABLE customers (customer_name VARCHAR, customer_id VARCHAR); CREATE TABLE customer_orders (customer_id VARCHAR) | SELECT T1.customer_name FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id WHERE shipping_method_code = 'FedEx' AND order_status_code = 'Paid' | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE customers (customer_name VARCHAR, customer_id VARCHAR); CREATE TABLE customer_orders (customer_id VARCHAR) Question: Show the names of customers having an order with shipping method FedEx and order status Paid. [/INST] SELECT T1.customer_name FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id WHERE shipping_method_code = 'FedEx' AND order_status_code = 'Paid' </s> |
How many courses are there in total? | CREATE TABLE COURSE (Id VARCHAR) | SELECT COUNT(*) FROM COURSE | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE COURSE (Id VARCHAR) Question: How many courses are there in total? [/INST] SELECT COUNT(*) FROM COURSE </s> |
How many courses have more than 2 credits? | CREATE TABLE COURSE (Credits INTEGER) | SELECT COUNT(*) FROM COURSE WHERE Credits > 2 | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE COURSE (Credits INTEGER) Question: How many courses have more than 2 credits? [/INST] SELECT COUNT(*) FROM COURSE WHERE Credits > 2 </s> |
List all names of courses with 1 credit? | CREATE TABLE COURSE (CName VARCHAR, Credits VARCHAR) | SELECT CName FROM COURSE WHERE Credits = 1 | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE COURSE (CName VARCHAR, Credits VARCHAR) Question: List all names of courses with 1 credit? [/INST] SELECT CName FROM COURSE WHERE Credits = 1 </s> |
Which courses are taught on days MTW? | CREATE TABLE COURSE (CName VARCHAR, Days VARCHAR) | SELECT CName FROM COURSE WHERE Days = "MTW" | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE COURSE (CName VARCHAR, Days VARCHAR) Question: Which courses are taught on days MTW? [/INST] SELECT CName FROM COURSE WHERE Days = "MTW" </s> |
What is the number of departments in Division "AS"? | CREATE TABLE DEPARTMENT (Division VARCHAR) | SELECT COUNT(*) FROM DEPARTMENT WHERE Division = "AS" | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE DEPARTMENT (Division VARCHAR) Question: What is the number of departments in Division "AS"? [/INST] SELECT COUNT(*) FROM DEPARTMENT WHERE Division = "AS" </s> |
What are the phones of departments in Room 268? | CREATE TABLE DEPARTMENT (DPhone VARCHAR, Room VARCHAR) | SELECT DPhone FROM DEPARTMENT WHERE Room = 268 | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE DEPARTMENT (DPhone VARCHAR, Room VARCHAR) Question: What are the phones of departments in Room 268? [/INST] SELECT DPhone FROM DEPARTMENT WHERE Room = 268 </s> |
Find the number of students that have at least one grade "B". | CREATE TABLE ENROLLED_IN (StuID VARCHAR, Grade VARCHAR) | SELECT COUNT(DISTINCT StuID) FROM ENROLLED_IN WHERE Grade = "B" | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE ENROLLED_IN (StuID VARCHAR, Grade VARCHAR) Question: Find the number of students that have at least one grade "B". [/INST] SELECT COUNT(DISTINCT StuID) FROM ENROLLED_IN WHERE Grade = "B" </s> |
Find the max and min grade point for all letter grade. | CREATE TABLE GRADECONVERSION (gradepoint INTEGER) | SELECT MAX(gradepoint), MIN(gradepoint) FROM GRADECONVERSION | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE GRADECONVERSION (gradepoint INTEGER) Question: Find the max and min grade point for all letter grade. [/INST] SELECT MAX(gradepoint), MIN(gradepoint) FROM GRADECONVERSION </s> |
Find the first names of students whose first names contain letter "a". | CREATE TABLE STUDENT (Fname VARCHAR) | SELECT DISTINCT Fname FROM STUDENT WHERE Fname LIKE '%a%' | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE STUDENT (Fname VARCHAR) Question: Find the first names of students whose first names contain letter "a". [/INST] SELECT DISTINCT Fname FROM STUDENT WHERE Fname LIKE '%a%' </s> |
Find the first names and last names of male (sex is M) faculties who live in building NEB. | CREATE TABLE FACULTY (Fname VARCHAR, Lname VARCHAR, sex VARCHAR, Building VARCHAR) | SELECT Fname, Lname FROM FACULTY WHERE sex = "M" AND Building = "NEB" | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE FACULTY (Fname VARCHAR, Lname VARCHAR, sex VARCHAR, Building VARCHAR) Question: Find the first names and last names of male (sex is M) faculties who live in building NEB. [/INST] SELECT Fname, Lname FROM FACULTY WHERE sex = "M" AND Building = "NEB" </s> |
Find the rooms of faculties with rank professor who live in building NEB. | CREATE TABLE FACULTY (Room VARCHAR, Rank VARCHAR, Building VARCHAR) | SELECT Room FROM FACULTY WHERE Rank = "Professor" AND Building = "NEB" | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE FACULTY (Room VARCHAR, Rank VARCHAR, Building VARCHAR) Question: Find the rooms of faculties with rank professor who live in building NEB. [/INST] SELECT Room FROM FACULTY WHERE Rank = "Professor" AND Building = "NEB" </s> |
Find the department name that is in Building "Mergenthaler". | CREATE TABLE DEPARTMENT (DName VARCHAR, Building VARCHAR) | SELECT DName FROM DEPARTMENT WHERE Building = "Mergenthaler" | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE DEPARTMENT (DName VARCHAR, Building VARCHAR) Question: Find the department name that is in Building "Mergenthaler". [/INST] SELECT DName FROM DEPARTMENT WHERE Building = "Mergenthaler" </s> |
List all information about courses sorted by credits in the ascending order. | CREATE TABLE COURSE (Credits VARCHAR) | SELECT * FROM COURSE ORDER BY Credits | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE COURSE (Credits VARCHAR) Question: List all information about courses sorted by credits in the ascending order. [/INST] SELECT * FROM COURSE ORDER BY Credits </s> |
List the course name of courses sorted by credits. | CREATE TABLE COURSE (CName VARCHAR, Credits VARCHAR) | SELECT CName FROM COURSE ORDER BY Credits | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE COURSE (CName VARCHAR, Credits VARCHAR) Question: List the course name of courses sorted by credits. [/INST] SELECT CName FROM COURSE ORDER BY Credits </s> |
Find the first name of students in the descending order of age. | CREATE TABLE STUDENT (Fname VARCHAR, Age VARCHAR) | SELECT Fname FROM STUDENT ORDER BY Age DESC | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE STUDENT (Fname VARCHAR, Age VARCHAR) Question: Find the first name of students in the descending order of age. [/INST] SELECT Fname FROM STUDENT ORDER BY Age DESC </s> |
Find the last name of female (sex is F) students in the descending order of age. | CREATE TABLE STUDENT (LName VARCHAR, Sex VARCHAR, Age VARCHAR) | SELECT LName FROM STUDENT WHERE Sex = "F" ORDER BY Age DESC | <s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE STUDENT (LName VARCHAR, Sex VARCHAR, Age VARCHAR) Question: Find the last name of female (sex is F) students in the descending order of age. [/INST] SELECT LName FROM STUDENT WHERE Sex = "F" ORDER BY Age DESC </s> |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.