Question: List the name of a building along with the name of a company whose office is in the building.

Context: CREATE TABLE buildings (name VARCHAR, id VARCHAR); CREATE TABLE Office_locations (building_id VARCHAR, company_id VARCHAR); CREATE TABLE Companies (name VARCHAR, id VARCHAR)

Answer: [SQL] 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 [/SQL]


Question: Show the names of the buildings that have more than one company offices.

Context: CREATE TABLE buildings (name VARCHAR, id VARCHAR); CREATE TABLE Companies (id VARCHAR); CREATE TABLE Office_locations (building_id VARCHAR, company_id VARCHAR)

Answer: [SQL] 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 [/SQL]


Question: Show the name of the building that has the most company offices.

Answer: [SQL] 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 ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: Please show the names of the buildings whose status is "on-hold", in ascending order of stories.

Context: CREATE TABLE buildings (name VARCHAR, Status VARCHAR, Stories VARCHAR)

Answer: [SQL] SELECT name FROM buildings WHERE Status = "on-hold" ORDER BY Stories [/SQL]


Question: Please show each industry and the corresponding number of companies in that industry.

Context: CREATE TABLE Companies (Industry VARCHAR)

Answer: [SQL] SELECT Industry, COUNT(*) FROM Companies GROUP BY Industry [/SQL]


Question: Please show the industries of companies in descending order of the number of companies.

Answer: [SQL] SELECT Industry FROM Companies GROUP BY Industry ORDER BY COUNT(*) DESC [/SQL]


Question: List the industry shared by the most companies.

Answer: [SQL] SELECT Industry FROM Companies GROUP BY Industry ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: List the names of buildings that have no company office.

Context: CREATE TABLE buildings (name VARCHAR, id VARCHAR, building_id VARCHAR); CREATE TABLE Office_locations (name VARCHAR, id VARCHAR, building_id VARCHAR)

Answer: [SQL] SELECT name FROM buildings WHERE NOT id IN (SELECT building_id FROM Office_locations) [/SQL]


Question: Show the industries shared by companies whose headquarters are "USA" and companies whose headquarters are "China".

Context: CREATE TABLE Companies (Industry VARCHAR, Headquarters VARCHAR)

Answer: [SQL] SELECT Industry FROM Companies WHERE Headquarters = "USA" INTERSECT SELECT Industry FROM Companies WHERE Headquarters = "China" [/SQL]


Question: Find the number of companies whose industry is "Banking" or "Conglomerate",

Answer: [SQL] SELECT COUNT(*) FROM Companies WHERE Industry = "Banking" OR Industry = "Conglomerate" [/SQL]


Question: Show the headquarters shared by more than two companies.

Context: CREATE TABLE Companies (Headquarters VARCHAR)

Answer: [SQL] SELECT Headquarters FROM Companies GROUP BY Headquarters HAVING COUNT(*) > 2 [/SQL]


Question: How many products are there?

Context: CREATE TABLE Products (Id VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM Products [/SQL]


Question: List the name of products in ascending order of price.

Context: CREATE TABLE Products (Product_Name VARCHAR, Product_Price VARCHAR)

Answer: [SQL] SELECT Product_Name FROM Products ORDER BY Product_Price [/SQL]


Question: What are the names and type codes of products?

Context: CREATE TABLE Products (Product_Name VARCHAR, Product_Type_Code VARCHAR)

Answer: [SQL] SELECT Product_Name, Product_Type_Code FROM Products [/SQL]


Question: Show the prices of the products named "Dining" or "Trading Policy".

Context: CREATE TABLE Products (Product_Price VARCHAR, Product_Name VARCHAR)

Answer: [SQL] SELECT Product_Price FROM Products WHERE Product_Name = "Dining" OR Product_Name = "Trading Policy" [/SQL]


Question: What is the average price for products?

Context: CREATE TABLE Products (Product_Price INTEGER)

Answer: [SQL] SELECT AVG(Product_Price) FROM Products [/SQL]


Question: What is the name of the product with the highest price?

Answer: [SQL] SELECT Product_Name FROM Products ORDER BY Product_Price DESC LIMIT 1 [/SQL]


Question: Show different type codes of products and the number of products with each type code.

Context: CREATE TABLE Products (Product_Type_Code VARCHAR)

Answer: [SQL] SELECT Product_Type_Code, COUNT(*) FROM Products GROUP BY Product_Type_Code [/SQL]


Question: Show the most common type code across products.

Answer: [SQL] SELECT Product_Type_Code FROM Products GROUP BY Product_Type_Code ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: Show the product type codes that have at least two products.

Answer: [SQL] SELECT Product_Type_Code FROM Products GROUP BY Product_Type_Code HAVING COUNT(*) >= 2 [/SQL]


Question: Show the product type codes that have both products with price higher than 4500 and products with price lower than 3000.

Context: CREATE TABLE Products (Product_Type_Code VARCHAR, Product_Price INTEGER)

Answer: [SQL] SELECT Product_Type_Code FROM Products WHERE Product_Price > 4500 INTERSECT SELECT Product_Type_Code FROM Products WHERE Product_Price < 3000 [/SQL]


Question: Show the names of products and the number of events they are in.

Context: CREATE TABLE Products (Product_Name VARCHAR, Product_ID VARCHAR); CREATE TABLE Products_in_Events (Product_ID VARCHAR)

Answer: [SQL] 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 [/SQL]


Question: Show the names of products and the number of events they are in, sorted by the number of events in descending order.

Answer: [SQL] 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 [/SQL]


Question: Show the names of products that are in at least two events.

Answer: [SQL] 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 [/SQL]


Question: Show the names of products that are in at least two events in ascending alphabetical order of product name.

Answer: [SQL] 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 [/SQL]


Question: List the names of products that are not in any event.

Context: CREATE TABLE Products (Product_Name VARCHAR, Product_ID VARCHAR); CREATE TABLE Products_in_Events (Product_Name VARCHAR, Product_ID VARCHAR)

Answer: [SQL] SELECT Product_Name FROM Products WHERE NOT Product_ID IN (SELECT Product_ID FROM Products_in_Events) [/SQL]


Question: How many artworks are there?

Context: CREATE TABLE artwork (Id VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM artwork [/SQL]


Question: List the name of artworks in ascending alphabetical order.

Context: CREATE TABLE artwork (Name VARCHAR)

Answer: [SQL] SELECT Name FROM artwork ORDER BY Name [/SQL]


Question: List the name of artworks whose type is not "Program Talent Show".

Context: CREATE TABLE artwork (Name VARCHAR, TYPE VARCHAR)

Answer: [SQL] SELECT Name FROM artwork WHERE TYPE <> "Program Talent Show" [/SQL]


Question: What are the names and locations of festivals?

Context: CREATE TABLE festival_detail (Festival_Name VARCHAR, LOCATION VARCHAR)

Answer: [SQL] SELECT Festival_Name, LOCATION FROM festival_detail [/SQL]


Question: What are the names of the chairs of festivals, sorted in ascending order of the year held?

Context: CREATE TABLE festival_detail (Chair_Name VARCHAR, YEAR VARCHAR)

Answer: [SQL] SELECT Chair_Name FROM festival_detail ORDER BY YEAR [/SQL]


Question: What is the location of the festival with the largest number of audience?

Context: CREATE TABLE festival_detail (LOCATION VARCHAR, Num_of_Audience VARCHAR)

Answer: [SQL] SELECT LOCATION FROM festival_detail ORDER BY Num_of_Audience DESC LIMIT 1 [/SQL]


Question: What are the names of festivals held in year 2007?

Context: CREATE TABLE festival_detail (Festival_Name VARCHAR, YEAR VARCHAR)

Answer: [SQL] SELECT Festival_Name FROM festival_detail WHERE YEAR = 2007 [/SQL]


Question: What is the average number of audience for festivals?

Context: CREATE TABLE festival_detail (Num_of_Audience INTEGER)

Answer: [SQL] SELECT AVG(Num_of_Audience) FROM festival_detail [/SQL]


Question: Show the names of the three most recent festivals.

Answer: [SQL] SELECT Festival_Name FROM festival_detail ORDER BY YEAR DESC LIMIT 3 [/SQL]


Question: For each nomination, show the name of the artwork and name of the festival where it is nominated.

Context: 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)

Answer: [SQL] 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 [/SQL]


Question: Show distinct types of artworks that are nominated in festivals in 2007.

Context: 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)

Answer: [SQL] 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 [/SQL]


Question: Show the names of artworks in ascending order of the year they are nominated in.

Context: 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)

Answer: [SQL] 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 [/SQL]


Question: Show the names of festivals that have nominated artworks of type "Program Talent Show".

Context: 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)

Answer: [SQL] 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" [/SQL]


Question: Show the ids and names of festivals that have at least two nominations for artworks.

Context: 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)

Answer: [SQL] 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 [/SQL]


Question: Show the id, name of each festival and the number of artworks it has nominated.

Answer: [SQL] 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 [/SQL]


Question: Please show different types of artworks with the corresponding number of artworks of each type.

Context: CREATE TABLE artwork (TYPE VARCHAR)

Answer: [SQL] SELECT TYPE, COUNT(*) FROM artwork GROUP BY TYPE [/SQL]


Question: List the most common type of artworks.

Context: CREATE TABLE artwork (TYPE VARCHAR)

Answer: [SQL] SELECT TYPE FROM artwork GROUP BY TYPE ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: List the year in which there are more than one festivals.

Context: CREATE TABLE festival_detail (YEAR VARCHAR)

Answer: [SQL] SELECT YEAR FROM festival_detail GROUP BY YEAR HAVING COUNT(*) > 1 [/SQL]


Question: List the name of artworks that are not nominated.

Context: CREATE TABLE nomination (Name VARCHAR, Artwork_ID VARCHAR); CREATE TABLE Artwork (Name VARCHAR, Artwork_ID VARCHAR)

Answer: [SQL] SELECT Name FROM Artwork WHERE NOT Artwork_ID IN (SELECT Artwork_ID FROM nomination) [/SQL]


Question: Show the number of audience in year 2008 or 2010.

Context: CREATE TABLE festival_detail (Num_of_Audience VARCHAR, YEAR VARCHAR)

Answer: [SQL] SELECT Num_of_Audience FROM festival_detail WHERE YEAR = 2008 OR YEAR = 2010 [/SQL]


Question: What are the total number of the audiences who visited any of the festivals?

Answer: [SQL] SELECT SUM(Num_of_Audience) FROM festival_detail [/SQL]


Question: In which year are there festivals both inside the 'United States' and outside the 'United States'?

Context: CREATE TABLE festival_detail (YEAR VARCHAR, LOCATION VARCHAR)

Answer: [SQL] SELECT YEAR FROM festival_detail WHERE LOCATION = 'United States' INTERSECT SELECT YEAR FROM festival_detail WHERE LOCATION <> 'United States' [/SQL]


Question: How many premises are there?

Context: CREATE TABLE premises (Id VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM premises [/SQL]


Question: What are all the distinct premise types?

Context: CREATE TABLE premises (premises_type VARCHAR)

Answer: [SQL] SELECT DISTINCT premises_type FROM premises [/SQL]


Question: Find the types and details for all premises and order by the premise type.

Context: CREATE TABLE premises (premises_type VARCHAR, premise_details VARCHAR)

Answer: [SQL] SELECT premises_type, premise_details FROM premises ORDER BY premises_type [/SQL]


Question: Show each premise type and the number of premises in that type.

Answer: [SQL] SELECT premises_type, COUNT(*) FROM premises GROUP BY premises_type [/SQL]


Question: Show all distinct product categories along with the number of mailshots in each category.

Context: CREATE TABLE mailshot_campaigns (product_category VARCHAR)

Answer: [SQL] SELECT product_category, COUNT(*) FROM mailshot_campaigns GROUP BY product_category [/SQL]


Question: Show the name and phone of the customer without any mailshot.

Context: 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)

Answer: [SQL] SELECT customer_name, customer_phone FROM customers WHERE NOT customer_id IN (SELECT customer_id FROM mailshot_customers) [/SQL]


Question: Show the name and phone for customers with a mailshot with outcome code 'No Response'.

Context: CREATE TABLE customers (customer_name VARCHAR, customer_phone VARCHAR, customer_id VARCHAR); CREATE TABLE mailshot_customers (customer_id VARCHAR, outcome_code VARCHAR)

Answer: [SQL] 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' [/SQL]


Question: Show the outcome code of mailshots along with the number of mailshots in each outcome code.

Context: CREATE TABLE mailshot_customers (outcome_code VARCHAR)

Answer: [SQL] SELECT outcome_code, COUNT(*) FROM mailshot_customers GROUP BY outcome_code [/SQL]


Question: Show the names of customers who have at least 2 mailshots with outcome code 'Order'.

Context: CREATE TABLE customers (customer_name VARCHAR, customer_id VARCHAR); CREATE TABLE mailshot_customers (customer_id VARCHAR)

Answer: [SQL] 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 [/SQL]


Question: Show the names of customers who have the most mailshots.

Answer: [SQL] SELECT 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 LIMIT 1 [/SQL]


Question: What are the name and payment method of customers who have both mailshots in 'Order' outcome and mailshots in 'No Response' outcome.

Context: CREATE TABLE customers (customer_name VARCHAR, payment_method VARCHAR, customer_id VARCHAR); CREATE TABLE mailshot_customers (customer_id VARCHAR, outcome_code VARCHAR)

Answer: [SQL] 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' [/SQL]


Question: Show the premise type and address type code for all customer addresses.

Context: CREATE TABLE premises (premises_type VARCHAR, premise_id VARCHAR); CREATE TABLE customer_addresses (address_type_code VARCHAR, premise_id VARCHAR)

Answer: [SQL] SELECT T2.premises_type, T1.address_type_code FROM customer_addresses AS T1 JOIN premises AS T2 ON T1.premise_id = T2.premise_id [/SQL]


Question: What are the distinct address type codes for all customer addresses?

Context: CREATE TABLE customer_addresses (address_type_code VARCHAR)

Answer: [SQL] SELECT DISTINCT address_type_code FROM customer_addresses [/SQL]


Question: Show the shipping charge and customer id for customer orders with order status Cancelled or Paid.

Context: CREATE TABLE customer_orders (order_shipping_charges VARCHAR, customer_id VARCHAR, order_status_code VARCHAR)

Answer: [SQL] SELECT order_shipping_charges, customer_id FROM customer_orders WHERE order_status_code = 'Cancelled' OR order_status_code = 'Paid' [/SQL]


Question: Show the names of customers having an order with shipping method FedEx and order status Paid.

Context: CREATE TABLE customers (customer_name VARCHAR, customer_id VARCHAR); CREATE TABLE customer_orders (customer_id VARCHAR)

Answer: [SQL] 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' [/SQL]


Question: How many courses are there in total?

Context: CREATE TABLE COURSE (Id VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM COURSE [/SQL]


Question: How many courses have more than 2 credits?

Context: CREATE TABLE COURSE (Credits INTEGER)

Answer: [SQL] SELECT COUNT(*) FROM COURSE WHERE Credits > 2 [/SQL]


Question: List all names of courses with 1 credit?

Context: CREATE TABLE COURSE (CName VARCHAR, Credits VARCHAR)

Answer: [SQL] SELECT CName FROM COURSE WHERE Credits = 1 [/SQL]


Question: Which courses are taught on days MTW?

Context: CREATE TABLE COURSE (CName VARCHAR, Days VARCHAR)

Answer: [SQL] SELECT CName FROM COURSE WHERE Days = "MTW" [/SQL]


Question: What is the number of departments in Division "AS"?

Context: CREATE TABLE DEPARTMENT (Division VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM DEPARTMENT WHERE Division = "AS" [/SQL]


Question: What are the phones of departments in Room 268?

Context: CREATE TABLE DEPARTMENT (DPhone VARCHAR, Room VARCHAR)

Answer: [SQL] SELECT DPhone FROM DEPARTMENT WHERE Room = 268 [/SQL]


Question: Find the number of students that have at least one grade "B".

Context: CREATE TABLE ENROLLED_IN (StuID VARCHAR, Grade VARCHAR)

Answer: [SQL] SELECT COUNT(DISTINCT StuID) FROM ENROLLED_IN WHERE Grade = "B" [/SQL]


Question: Find the max and min grade point for all letter grade.

Context: CREATE TABLE GRADECONVERSION (gradepoint INTEGER)

Answer: [SQL] SELECT MAX(gradepoint), MIN(gradepoint) FROM GRADECONVERSION [/SQL]


Question: Find the first names of students whose first names contain letter "a".

Context: CREATE TABLE STUDENT (Fname VARCHAR)

Answer: [SQL] SELECT DISTINCT Fname FROM STUDENT WHERE Fname LIKE '%a%' [/SQL]


Question: Find the first names and last names of male (sex is M) faculties who live in building NEB.

Context: CREATE TABLE FACULTY (Fname VARCHAR, Lname VARCHAR, sex VARCHAR, Building VARCHAR)

Answer: [SQL] SELECT Fname, Lname FROM FACULTY WHERE sex = "M" AND Building = "NEB" [/SQL]


Question: Find the rooms of faculties with rank professor who live in building NEB.

Context: CREATE TABLE FACULTY (Room VARCHAR, Rank VARCHAR, Building VARCHAR)

Answer: [SQL] SELECT Room FROM FACULTY WHERE Rank = "Professor" AND Building = "NEB" [/SQL]


Question: Find the department name that is in Building "Mergenthaler".

Context: CREATE TABLE DEPARTMENT (DName VARCHAR, Building VARCHAR)

Answer: [SQL] SELECT DName FROM DEPARTMENT WHERE Building = "Mergenthaler" [/SQL]


Question: List all information about courses sorted by credits in the ascending order.

Context: CREATE TABLE COURSE (Credits VARCHAR)

Answer: [SQL] SELECT * FROM COURSE ORDER BY Credits [/SQL]


Question: List the course name of courses sorted by credits.

Answer: [SQL] SELECT CName FROM COURSE ORDER BY Credits [/SQL]


Question: Find the first name of students in the descending order of age.

Context: CREATE TABLE STUDENT (Fname VARCHAR, Age VARCHAR)

Answer: [SQL] SELECT Fname FROM STUDENT ORDER BY Age DESC [/SQL]


Question: Find the last name of female (sex is F) students in the descending order of age.

Context: CREATE TABLE STUDENT (LName VARCHAR, Sex VARCHAR, Age VARCHAR)

Answer: [SQL] SELECT LName FROM STUDENT WHERE Sex = "F" ORDER BY Age DESC [/SQL]


Question: Find the last names of faculties in building Barton in alphabetic order.

Context: CREATE TABLE FACULTY (Lname VARCHAR, Building VARCHAR)

Answer: [SQL] SELECT Lname FROM FACULTY WHERE Building = "Barton" ORDER BY Lname [/SQL]


Question: Find the first names of faculties of rank Professor in alphabetic order.

Context: CREATE TABLE FACULTY (Fname VARCHAR, Rank VARCHAR)

Answer: [SQL] SELECT Fname FROM FACULTY WHERE Rank = "Professor" ORDER BY Fname [/SQL]


Question: Find the name of the department that has the biggest number of students minored in?

Context: CREATE TABLE DEPARTMENT (DName VARCHAR, DNO VARCHAR); CREATE TABLE MINOR_IN (DNO VARCHAR)

Answer: [SQL] SELECT T1.DName FROM DEPARTMENT AS T1 JOIN MINOR_IN AS T2 ON T1.DNO = T2.DNO GROUP BY T2.DNO ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: Find the name of the department that has no students minored in?

Context: CREATE TABLE DEPARTMENT (DName VARCHAR, DNO VARCHAR); CREATE TABLE MINOR_IN (DNO VARCHAR); CREATE TABLE DEPARTMENT (DName VARCHAR)

Answer: [SQL] SELECT DName FROM DEPARTMENT EXCEPT SELECT T1.DName FROM DEPARTMENT AS T1 JOIN MINOR_IN AS T2 ON T1.DNO = T2.DNO [/SQL]


Question: Find the name of the department that has the fewest members.

Context: CREATE TABLE MEMBER_OF (DNO VARCHAR); CREATE TABLE DEPARTMENT (DName VARCHAR, DNO VARCHAR)

Answer: [SQL] SELECT T1.DName FROM DEPARTMENT AS T1 JOIN MEMBER_OF AS T2 ON T1.DNO = T2.DNO GROUP BY T2.DNO ORDER BY COUNT(*) LIMIT 1 [/SQL]


Question: Find the rank of the faculty that the fewest faculties belong to.

Context: CREATE TABLE FACULTY (Rank VARCHAR)

Answer: [SQL] SELECT Rank FROM FACULTY GROUP BY Rank ORDER BY COUNT(*) LIMIT 1 [/SQL]


Question: What are the first and last names of the instructors who teach the top 3 number of courses?

Context: CREATE TABLE COURSE (Instructor VARCHAR); CREATE TABLE FACULTY (Fname VARCHAR, Lname VARCHAR, FacID VARCHAR)

Answer: [SQL] SELECT T2.Fname, T2.Lname FROM COURSE AS T1 JOIN FACULTY AS T2 ON T1.Instructor = T2.FacID GROUP BY T1.Instructor ORDER BY COUNT(*) DESC LIMIT 3 [/SQL]


Question: Which building does the instructor who teaches the most number of courses live in?

Context: CREATE TABLE COURSE (Instructor VARCHAR); CREATE TABLE FACULTY (Building VARCHAR, FacID VARCHAR)

Answer: [SQL] SELECT T2.Building FROM COURSE AS T1 JOIN FACULTY AS T2 ON T1.Instructor = T2.FacID GROUP BY T1.Instructor ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: What are the name of courses that have at least five enrollments?

Context: CREATE TABLE ENROLLED_IN (CID VARCHAR); CREATE TABLE COURSE (CName VARCHAR, CID VARCHAR)

Answer: [SQL] SELECT T1.CName FROM COURSE AS T1 JOIN ENROLLED_IN AS T2 ON T1.CID = T2.CID GROUP BY T2.CID HAVING COUNT(*) >= 5 [/SQL]


Question: Find the first name and last name of the instructor of course that has course name

Context: CREATE TABLE FACULTY (Fname VARCHAR, Lname VARCHAR, FacID VARCHAR); CREATE TABLE COURSE (Instructor VARCHAR, CName VARCHAR)

Answer: [SQL] SELECT T2.Fname, T2.Lname FROM COURSE AS T1 JOIN FACULTY AS T2 ON T1.Instructor = T2.FacID WHERE T1.CName = "COMPUTER LITERACY" [/SQL]


Question: Find the department name and room of the course INTRODUCTION TO COMPUTER SCIENCE.

Context: CREATE TABLE COURSE (DNO VARCHAR, CName VARCHAR); CREATE TABLE DEPARTMENT (Dname VARCHAR, Room VARCHAR, DNO VARCHAR)

Answer: [SQL] SELECT T2.Dname, T2.Room FROM COURSE AS T1 JOIN DEPARTMENT AS T2 ON T1.DNO = T2.DNO WHERE T1.CName = "INTRODUCTION TO COMPUTER SCIENCE" [/SQL]


Question: Find the student first and last names and grade points of all enrollments.

Context: CREATE TABLE ENROLLED_IN (Grade VARCHAR, StuID VARCHAR); CREATE TABLE STUDENT (Fname VARCHAR, LName VARCHAR, StuID VARCHAR); CREATE TABLE GRADECONVERSION (gradepoint VARCHAR, lettergrade VARCHAR)

Answer: [SQL] SELECT T3.Fname, T3.LName, T2.gradepoint FROM ENROLLED_IN AS T1 JOIN GRADECONVERSION AS T2 JOIN STUDENT AS T3 ON T1.Grade = T2.lettergrade AND T1.StuID = T3.StuID [/SQL]


Question: Find the distinct student first names of all students that have grade point at least 3.8 in one course.

Context: CREATE TABLE ENROLLED_IN (Grade VARCHAR, StuID VARCHAR); CREATE TABLE STUDENT (Fname VARCHAR, StuID VARCHAR); CREATE TABLE GRADECONVERSION (gradepoint VARCHAR, lettergrade VARCHAR)

Answer: [SQL] SELECT DISTINCT T3.Fname FROM ENROLLED_IN AS T1 JOIN GRADECONVERSION AS T2 JOIN STUDENT AS T3 ON T1.Grade = T2.lettergrade AND T1.StuID = T3.StuID WHERE T2.gradepoint >= 3.8 [/SQL]


Question: Find the full names of faculties who are members of department with department number 520.

Context: CREATE TABLE FACULTY (Fname VARCHAR, Lname VARCHAR, FacID VARCHAR); CREATE TABLE MEMBER_OF (FacID VARCHAR, DNO VARCHAR)

Answer: [SQL] SELECT T1.Fname, T1.Lname FROM FACULTY AS T1 JOIN MEMBER_OF AS T2 ON T1.FacID = T2.FacID WHERE T2.DNO = 520 [/SQL]


Question: What are the first names and last names of the students that minor in the department with DNO 140.

Context: CREATE TABLE STUDENT (Fname VARCHAR, Lname VARCHAR, StuID VARCHAR); CREATE TABLE MINOR_IN (StuID VARCHAR, DNO VARCHAR)

Answer: [SQL] SELECT T2.Fname, T2.Lname FROM MINOR_IN AS T1 JOIN STUDENT AS T2 ON T1.StuID = T2.StuID WHERE T1.DNO = 140 [/SQL]


Question: Find the last names of faculties who are members of computer science department.

Context: CREATE TABLE DEPARTMENT (DNO VARCHAR, DName VARCHAR); CREATE TABLE MEMBER_OF (DNO VARCHAR, FacID VARCHAR); CREATE TABLE FACULTY (Lname VARCHAR, FacID VARCHAR)

Answer: [SQL] SELECT T2.Lname FROM DEPARTMENT AS T1 JOIN FACULTY AS T2 ON T1.DNO = T3.DNO JOIN MEMBER_OF AS T3 ON T2.FacID = T3.FacID WHERE T1.DName = "Computer Science" [/SQL]


Question: Find the average grade point of student whose last name is Smith.

Context: CREATE TABLE ENROLLED_IN (Grade VARCHAR, StuID VARCHAR); CREATE TABLE STUDENT (LName VARCHAR, StuID VARCHAR); CREATE TABLE GRADECONVERSION (gradepoint INTEGER, lettergrade VARCHAR)

Answer: [SQL] SELECT AVG(T2.gradepoint) FROM ENROLLED_IN AS T1 JOIN GRADECONVERSION AS T2 JOIN STUDENT AS T3 ON T1.Grade = T2.lettergrade AND T1.StuID = T3.StuID WHERE T3.LName = "Smith" [/SQL]


Question: What is the maximum and minimum grade point of students who live in NYC?

Context: CREATE TABLE ENROLLED_IN (Grade VARCHAR, StuID VARCHAR); CREATE TABLE STUDENT (city_code VARCHAR, StuID VARCHAR); CREATE TABLE GRADECONVERSION (gradepoint INTEGER, lettergrade VARCHAR)

Answer: [SQL] SELECT MAX(T2.gradepoint), MIN(T2.gradepoint) FROM ENROLLED_IN AS T1 JOIN GRADECONVERSION AS T2 JOIN STUDENT AS T3 ON T1.Grade = T2.lettergrade AND T1.StuID = T3.StuID WHERE T3.city_code = "NYC" [/SQL]


Question: Find the names of courses that have either 3 credits or 1 credit but 4 hours.

Context: CREATE TABLE COURSE (CName VARCHAR, Credits VARCHAR, Hours VARCHAR)

Answer: [SQL] SELECT CName FROM COURSE WHERE Credits = 3 UNION SELECT CName FROM COURSE WHERE Credits = 1 AND Hours = 4 [/SQL]


Question: Find the names of departments that are either in division AS or in division EN and in Building NEB.

Context: CREATE TABLE DEPARTMENT (DName VARCHAR, Division VARCHAR, Building VARCHAR)

Answer: [SQL] SELECT DName FROM DEPARTMENT WHERE Division = "AS" UNION SELECT DName FROM DEPARTMENT WHERE Division = "EN" AND Building = "NEB" [/SQL]


Question: Find the first name of students not enrolled in any course.

Context: CREATE TABLE STUDENT (Fname VARCHAR, StuID VARCHAR); CREATE TABLE ENROLLED_IN (Fname VARCHAR, StuID VARCHAR)

Answer: [SQL] SELECT Fname FROM STUDENT WHERE NOT StuID IN (SELECT StuID FROM ENROLLED_IN) [/SQL]


Question: What are the ids of the top three products that were purchased in the largest amount?

Context: CREATE TABLE product_suppliers (product_id VARCHAR, total_amount_purchased VARCHAR)

Answer: [SQL] SELECT product_id FROM product_suppliers ORDER BY total_amount_purchased DESC LIMIT 3 [/SQL]


Question: What are the product id and product type of the cheapest product?

Context: CREATE TABLE products (product_id VARCHAR, product_type_code VARCHAR, product_price VARCHAR)

Answer: [SQL] SELECT product_id, product_type_code FROM products ORDER BY product_price LIMIT 1 [/SQL]


Question: Find the number of different product types.

Context: CREATE TABLE products (product_type_code VARCHAR)

Answer: [SQL] SELECT COUNT(DISTINCT product_type_code) FROM products [/SQL]


Question: Return the address of customer 10.

Context: CREATE TABLE customer_addresses (address_id VARCHAR, customer_id VARCHAR); CREATE TABLE addresses (address_details VARCHAR, address_id VARCHAR)

Answer: [SQL] SELECT T1.address_details FROM addresses AS T1 JOIN customer_addresses AS T2 ON T1.address_id = T2.address_id WHERE T2.customer_id = 10 [/SQL]


Question: What are the staff ids and genders of all staffs whose job title is Department Manager?

Context: CREATE TABLE staff_department_assignments (staff_id VARCHAR, job_title_code VARCHAR); CREATE TABLE staff (staff_id VARCHAR, staff_gender VARCHAR)

Answer: [SQL] SELECT T1.staff_id, T1.staff_gender FROM staff AS T1 JOIN staff_department_assignments AS T2 ON T1.staff_id = T2.staff_id WHERE T2.job_title_code = "Department Manager" [/SQL]


Question: For each payment method, return how many customers use it.

Context: CREATE TABLE customers (payment_method_code VARCHAR)

Answer: [SQL] SELECT payment_method_code, COUNT(*) FROM customers GROUP BY payment_method_code [/SQL]


Question: What is the id of the product that was ordered the most often?

Context: CREATE TABLE order_items (product_id VARCHAR)

Answer: [SQL] SELECT product_id FROM order_items GROUP BY product_id ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: What are the name, phone number and email address of the customer who made the largest number of orders?

Context: CREATE TABLE customers (customer_name VARCHAR, customer_phone VARCHAR, customer_email VARCHAR, customer_id VARCHAR); CREATE TABLE customer_orders (customer_id VARCHAR)

Answer: [SQL] SELECT T1.customer_name, T1.customer_phone, T1.customer_email FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id GROUP BY T2.customer_id ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: What is the average price for each type of product?

Context: CREATE TABLE products (product_type_code VARCHAR, product_price INTEGER)

Answer: [SQL] SELECT product_type_code, AVG(product_price) FROM products GROUP BY product_type_code [/SQL]


Question: How many department stores does the store chain South have?

Context: CREATE TABLE department_stores (dept_store_chain_id VARCHAR); CREATE TABLE department_store_chain (dept_store_chain_id VARCHAR, dept_store_chain_name VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM department_stores AS T1 JOIN department_store_chain AS T2 ON T1.dept_store_chain_id = T2.dept_store_chain_id WHERE T2.dept_store_chain_name = "South" [/SQL]


Question: What is the name and job title of the staff who was assigned the latest?

Context: CREATE TABLE staff (staff_name VARCHAR, staff_id VARCHAR); CREATE TABLE staff_department_assignments (job_title_code VARCHAR, staff_id VARCHAR, date_assigned_to VARCHAR)

Answer: [SQL] SELECT T1.staff_name, T2.job_title_code FROM staff AS T1 JOIN staff_department_assignments AS T2 ON T1.staff_id = T2.staff_id ORDER BY T2.date_assigned_to DESC LIMIT 1 [/SQL]


Question: Give me the product type, name and price for all the products supplied by supplier id 3.

Context: CREATE TABLE products (product_type_code VARCHAR, product_name VARCHAR, product_price VARCHAR, product_id VARCHAR); CREATE TABLE product_suppliers (product_id VARCHAR, supplier_id VARCHAR)

Answer: [SQL] SELECT T2.product_type_code, T2.product_name, T2.product_price FROM product_suppliers AS T1 JOIN products AS T2 ON T1.product_id = T2.product_id WHERE T1.supplier_id = 3 [/SQL]


Question: Return the distinct name of customers whose order status is Pending, in the order of customer id.

Context: CREATE TABLE customers (customer_name VARCHAR, customer_id VARCHAR); CREATE TABLE customer_orders (customer_id VARCHAR, order_status_code VARCHAR)

Answer: [SQL] SELECT DISTINCT T1.customer_name FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status_code = "Pending" ORDER BY T2.customer_id [/SQL]


Question: Find the name and address of the customers who have both New and Pending orders.

Context: CREATE TABLE customers (customer_name VARCHAR, customer_address VARCHAR, customer_id VARCHAR); CREATE TABLE customer_orders (customer_id VARCHAR, order_status_code VARCHAR)

Answer: [SQL] SELECT T1.customer_name, T1.customer_address FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status_code = "New" INTERSECT SELECT T1.customer_name, T1.customer_address FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status_code = "Pending" [/SQL]


Question: Return ids of all the products that are supplied by supplier id 2 and are more expensive than the average price of all products.

Context: CREATE TABLE products (product_id VARCHAR, product_price INTEGER); CREATE TABLE product_suppliers (product_id VARCHAR, supplier_id VARCHAR); CREATE TABLE products (product_price INTEGER)

Answer: [SQL] SELECT T1.product_id FROM product_suppliers AS T1 JOIN products AS T2 ON T1.product_id = T2.product_id WHERE T1.supplier_id = 2 AND T2.product_price > (SELECT AVG(product_price) FROM products) [/SQL]


Question: What is the id and name of the department store that has both marketing and managing department?

Context: CREATE TABLE department_stores (dept_store_id VARCHAR, store_name VARCHAR); CREATE TABLE departments (dept_store_id VARCHAR, department_name VARCHAR)

Answer: [SQL] SELECT T2.dept_store_id, T2.store_name FROM departments AS T1 JOIN department_stores AS T2 ON T1.dept_store_id = T2.dept_store_id WHERE T1.department_name = "marketing" INTERSECT SELECT T2.dept_store_id, T2.store_name FROM departments AS T1 JOIN department_stores AS T2 ON T1.dept_store_id = T2.dept_store_id WHERE T1.department_name = "managing" [/SQL]


Question: What are the ids of the two department store chains with the largest number of department stores?

Context: CREATE TABLE department_stores (dept_store_chain_id VARCHAR)

Answer: [SQL] SELECT dept_store_chain_id FROM department_stores GROUP BY dept_store_chain_id ORDER BY COUNT(*) DESC LIMIT 2 [/SQL]


Question: What is the id of the department with the least number of staff?

Context: CREATE TABLE staff_department_assignments (department_id VARCHAR)

Answer: [SQL] SELECT department_id FROM staff_department_assignments GROUP BY department_id ORDER BY COUNT(*) LIMIT 1 [/SQL]


Question: For each product type, return the maximum and minimum price.

Answer: [SQL] SELECT product_type_code, MAX(product_price), MIN(product_price) FROM products GROUP BY product_type_code [/SQL]


Question: Find the product type whose average price is higher than the average price of all products.

Answer: [SQL] SELECT product_type_code FROM products GROUP BY product_type_code HAVING AVG(product_price) > (SELECT AVG(product_price) FROM products) [/SQL]


Question: Find the id and name of the staff who has been assigned for the shortest period.

Context: CREATE TABLE Staff_Department_Assignments (staff_id VARCHAR); CREATE TABLE staff (staff_id VARCHAR, staff_name VARCHAR)

Answer: [SQL] SELECT T1.staff_id, T1.staff_name FROM staff AS T1 JOIN Staff_Department_Assignments AS T2 ON T1.staff_id = T2.staff_id ORDER BY date_assigned_to - date_assigned_from LIMIT 1 [/SQL]


Question: Return the names and ids of all products whose price is between 600 and 700.

Context: CREATE TABLE products (product_name VARCHAR, product_id VARCHAR, product_price INTEGER)

Answer: [SQL] SELECT product_name, product_id FROM products WHERE product_price BETWEEN 600 AND 700 [/SQL]


Question: Find the ids of all distinct customers who made order after some orders that were Cancelled.

Context: CREATE TABLE Customer_Orders (customer_id VARCHAR, order_date INTEGER, order_status_code VARCHAR)

Answer: [SQL] SELECT DISTINCT customer_id FROM Customer_Orders WHERE order_date > (SELECT MIN(order_date) FROM Customer_Orders WHERE order_status_code = "Cancelled") [/SQL]


Question: What is id of the staff who had a Staff Department Assignment earlier than any Clerical Staff?

Context: CREATE TABLE Staff_Department_Assignments (staff_id VARCHAR, date_assigned_to INTEGER, job_title_code VARCHAR)

Answer: [SQL] SELECT staff_id FROM Staff_Department_Assignments WHERE date_assigned_to < (SELECT MAX(date_assigned_to) FROM Staff_Department_Assignments WHERE job_title_code = 'Clerical Staff') [/SQL]


Question: What are the names and ids of customers whose address contains TN?

Context: CREATE TABLE customers (customer_name VARCHAR, customer_id VARCHAR, customer_address VARCHAR)

Answer: [SQL] SELECT customer_name, customer_id FROM customers WHERE customer_address LIKE "%TN%" [/SQL]


Question: Return the name and gender of the staff who was assigned in 2016.

Context: CREATE TABLE staff (staff_name VARCHAR, staff_gender VARCHAR, staff_id VARCHAR); CREATE TABLE staff_department_assignments (staff_id VARCHAR, date_assigned_from VARCHAR)

Answer: [SQL] SELECT T1.staff_name, T1.staff_gender FROM staff AS T1 JOIN staff_department_assignments AS T2 ON T1.staff_id = T2.staff_id WHERE T2.date_assigned_from LIKE "2016%" [/SQL]


Question: List the name of staff who has been assigned multiple jobs.

Context: CREATE TABLE staff (staff_name VARCHAR, staff_id VARCHAR); CREATE TABLE staff_department_assignments (staff_id VARCHAR)

Answer: [SQL] SELECT T1.staff_name FROM staff AS T1 JOIN staff_department_assignments AS T2 ON T1.staff_id = T2.staff_id GROUP BY T2.staff_id HAVING COUNT(*) > 1 [/SQL]


Question: List the name and phone number of all suppliers in the alphabetical order of their addresses.

Context: CREATE TABLE addresses (address_id VARCHAR, address_details VARCHAR); CREATE TABLE supplier_addresses (supplier_id VARCHAR, address_id VARCHAR); CREATE TABLE Suppliers (supplier_name VARCHAR, supplier_phone VARCHAR, supplier_id VARCHAR)

Answer: [SQL] SELECT T1.supplier_name, T1.supplier_phone FROM Suppliers AS T1 JOIN supplier_addresses AS T2 ON T1.supplier_id = T2.supplier_id JOIN addresses AS T3 ON T2.address_id = T3.address_id ORDER BY T3.address_details [/SQL]


Question: What are the phone numbers of all customers and suppliers.

Context: CREATE TABLE suppliers (customer_phone VARCHAR, supplier_phone VARCHAR); CREATE TABLE customers (customer_phone VARCHAR, supplier_phone VARCHAR)

Answer: [SQL] SELECT customer_phone FROM customers UNION SELECT supplier_phone FROM suppliers [/SQL]


Question: Return the ids of all products that were ordered more than three times or supplied more than 80000.

Context: CREATE TABLE Order_Items (product_id VARCHAR, total_amount_purchased INTEGER); CREATE TABLE Product_Suppliers (product_id VARCHAR, total_amount_purchased INTEGER)

Answer: [SQL] SELECT product_id FROM Order_Items GROUP BY product_id HAVING COUNT(*) > 3 UNION SELECT product_id FROM Product_Suppliers GROUP BY product_id HAVING SUM(total_amount_purchased) > 80000 [/SQL]


Question: What are id and name of the products whose price is lower than 600 or higher than 900?

Context: CREATE TABLE products (product_id VARCHAR, product_name VARCHAR, product_price VARCHAR)

Answer: [SQL] SELECT product_id, product_name FROM products WHERE product_price < 600 OR product_price > 900 [/SQL]


Question: Find the id of suppliers whose average amount purchased for each product is above 50000 or below 30000.

Context: CREATE TABLE Product_Suppliers (supplier_id VARCHAR, total_amount_purchased INTEGER)

Answer: [SQL] SELECT supplier_id FROM Product_Suppliers GROUP BY supplier_id HAVING AVG(total_amount_purchased) > 50000 OR AVG(total_amount_purchased) < 30000 [/SQL]


Question: What are the average amount purchased and value purchased for the supplier who supplies the most products.

Context: CREATE TABLE Product_Suppliers (total_amount_purchased INTEGER, total_value_purchased INTEGER, supplier_id VARCHAR)

Answer: [SQL] SELECT AVG(total_amount_purchased), AVG(total_value_purchased) FROM Product_Suppliers WHERE supplier_id = (SELECT supplier_id FROM Product_Suppliers GROUP BY supplier_id ORDER BY COUNT(*) DESC LIMIT 1) [/SQL]


Question: What is the largest and smallest customer codes?

Context: CREATE TABLE Customers (customer_code INTEGER)

Answer: [SQL] SELECT MAX(customer_code), MIN(customer_code) FROM Customers [/SQL]


Question: List the names of all the distinct customers who bought a keyboard.

Context: CREATE TABLE order_items (order_id VARCHAR, product_id VARCHAR); CREATE TABLE customers (customer_name VARCHAR, customer_id VARCHAR); CREATE TABLE products (product_id VARCHAR, product_name VARCHAR); CREATE TABLE customer_orders (customer_id VARCHAR, order_id VARCHAR)

Answer: [SQL] SELECT DISTINCT T1.customer_name FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id JOIN order_items AS T3 ON T2.order_id = T3.order_id JOIN products AS T4 ON T3.product_id = T4.product_id WHERE T4.product_name = "keyboard" [/SQL]


Question: List the names and phone numbers of all the distinct suppliers who supply red jeans.

Context: CREATE TABLE product_suppliers (supplier_id VARCHAR, product_id VARCHAR); CREATE TABLE suppliers (supplier_name VARCHAR, supplier_phone VARCHAR, supplier_id VARCHAR); CREATE TABLE products (product_id VARCHAR, product_name VARCHAR)

Answer: [SQL] SELECT DISTINCT T1.supplier_name, T1.supplier_phone FROM suppliers AS T1 JOIN product_suppliers AS T2 ON T1.supplier_id = T2.supplier_id JOIN products AS T3 ON T2.product_id = T3.product_id WHERE T3.product_name = "red jeans" [/SQL]


Question: What are the highest and lowest prices of products, grouped by and alphabetically ordered by product type?

Context: CREATE TABLE products (product_type_code VARCHAR, product_price INTEGER)

Answer: [SQL] SELECT MAX(product_price), MIN(product_price), product_type_code FROM products GROUP BY product_type_code ORDER BY product_type_code [/SQL]


Question: List the order id, customer id for orders in Cancelled status, ordered by their order dates.

Context: CREATE TABLE customer_orders (order_id VARCHAR, customer_id VARCHAR, order_status_code VARCHAR, order_date VARCHAR)

Answer: [SQL] SELECT order_id, customer_id FROM customer_orders WHERE order_status_code = "Cancelled" ORDER BY order_date [/SQL]


Question: Find the names of products that were bought by at least two distinct customers.

Context: CREATE TABLE products (product_name VARCHAR, product_id VARCHAR); CREATE TABLE customer_orders (order_id VARCHAR, customer_id VARCHAR); CREATE TABLE order_items (order_id VARCHAR, product_id VARCHAR)

Answer: [SQL] SELECT DISTINCT T3.product_name FROM customer_orders AS T1 JOIN order_items AS T2 ON T1.order_id = T2.order_id JOIN products AS T3 ON T2.product_id = T3.product_id GROUP BY T3.product_id HAVING COUNT(DISTINCT T1.customer_id) >= 2 [/SQL]


Question: Find the names of customers who have bought by at least three distinct products.

Context: CREATE TABLE order_items (order_id VARCHAR, product_id VARCHAR); CREATE TABLE customers (customer_name VARCHAR, customer_id VARCHAR); CREATE TABLE customer_orders (customer_id VARCHAR, order_id VARCHAR)

Answer: [SQL] SELECT DISTINCT T1.customer_name FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id JOIN order_items AS T3 ON T2.order_id = T3.order_id GROUP BY T1.customer_id HAVING COUNT(DISTINCT T3.product_id) >= 3 [/SQL]


Question: Find the name and gender of the staff who has been assigned the job of Sales Person but never Clerical Staff.

Context: CREATE TABLE staff (staff_name VARCHAR, staff_gender VARCHAR, staff_id VARCHAR); CREATE TABLE Staff_Department_Assignments (staff_id VARCHAR, job_title_code VARCHAR)

Answer: [SQL] SELECT T1.staff_name, T1.staff_gender FROM staff AS T1 JOIN Staff_Department_Assignments AS T2 ON T1.staff_id = T2.staff_id WHERE T2.job_title_code = "Sales Person" EXCEPT SELECT T1.staff_name, T1.staff_gender FROM staff AS T1 JOIN Staff_Department_Assignments AS T2 ON T1.staff_id = T2.staff_id WHERE T2.job_title_code = "Clerical Staff" [/SQL]


Question: Find the id and name of customers whose address contains WY state and do not use credit card for payment.

Context: CREATE TABLE customers (customer_id VARCHAR, customer_name VARCHAR, customer_address VARCHAR, payment_method_code VARCHAR)

Answer: [SQL] SELECT customer_id, customer_name FROM customers WHERE customer_address LIKE "%WY%" AND payment_method_code <> "Credit Card" [/SQL]


Question: Find the average price of all product clothes.

Context: CREATE TABLE products (product_price INTEGER, product_type_code VARCHAR)

Answer: [SQL] SELECT AVG(product_price) FROM products WHERE product_type_code = 'Clothes' [/SQL]


Question: Find the name of the most expensive hardware product.

Context: CREATE TABLE products (product_name VARCHAR, product_type_code VARCHAR, product_price VARCHAR)

Answer: [SQL] SELECT product_name FROM products WHERE product_type_code = 'Hardware' ORDER BY product_price DESC LIMIT 1 [/SQL]


Question: How many aircrafts are there?

Context: CREATE TABLE aircraft (Id VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM aircraft [/SQL]


Question: List the description of all aircrafts.

Context: CREATE TABLE aircraft (Description VARCHAR)

Answer: [SQL] SELECT Description FROM aircraft [/SQL]


Question: What is the average number of international passengers of all airports?

Context: CREATE TABLE airport (International_Passengers INTEGER)

Answer: [SQL] SELECT AVG(International_Passengers) FROM airport [/SQL]


Question: What are the number of international and domestic passengers of the airport named London "Heathrow"?

Context: CREATE TABLE airport (International_Passengers VARCHAR, Domestic_Passengers VARCHAR, Airport_Name VARCHAR)

Answer: [SQL] SELECT International_Passengers, Domestic_Passengers FROM airport WHERE Airport_Name = "London Heathrow" [/SQL]


Question: What are the total number of Domestic Passengers of airports that contain the word "London".

Context: CREATE TABLE airport (Domestic_Passengers INTEGER, Airport_Name VARCHAR)

Answer: [SQL] SELECT SUM(Domestic_Passengers) FROM airport WHERE Airport_Name LIKE "%London%" [/SQL]


Question: What are the maximum and minimum number of transit passengers of all aiports.

Context: CREATE TABLE airport (Transit_Passengers INTEGER)

Answer: [SQL] SELECT MAX(Transit_Passengers), MIN(Transit_Passengers) FROM airport [/SQL]


Question: What are the name of pilots aged 25 or older?

Context: CREATE TABLE pilot (Name VARCHAR, Age VARCHAR)

Answer: [SQL] SELECT Name FROM pilot WHERE Age >= 25 [/SQL]


Question: List all pilot names in ascending alphabetical order.

Context: CREATE TABLE pilot (Name VARCHAR)

Answer: [SQL] SELECT Name FROM pilot ORDER BY Name [/SQL]


Question: List names of all pilot aged 30 or younger in descending alphabetical order.

Answer: [SQL] SELECT Name FROM pilot WHERE Age <= 30 ORDER BY Name DESC [/SQL]


Question: Please show the names of aircrafts associated with airport with name "London Gatwick".

Context: CREATE TABLE airport (Airport_ID VARCHAR, Airport_Name VARCHAR); CREATE TABLE aircraft (Aircraft VARCHAR, Aircraft_ID VARCHAR); CREATE TABLE airport_aircraft (Aircraft_ID VARCHAR, Airport_ID VARCHAR)

Answer: [SQL] SELECT T1.Aircraft FROM aircraft AS T1 JOIN airport_aircraft AS T2 ON T1.Aircraft_ID = T2.Aircraft_ID JOIN airport AS T3 ON T2.Airport_ID = T3.Airport_ID WHERE T3.Airport_Name = "London Gatwick" [/SQL]


Question: Please show the names and descriptions of aircrafts associated with airports that have a total number of passengers bigger than 10000000.

Context: CREATE TABLE airport (Airport_ID VARCHAR, Total_Passengers INTEGER); CREATE TABLE aircraft (Aircraft VARCHAR, Description VARCHAR, Aircraft_ID VARCHAR); CREATE TABLE airport_aircraft (Aircraft_ID VARCHAR, Airport_ID VARCHAR)

Answer: [SQL] SELECT T1.Aircraft, T1.Description FROM aircraft AS T1 JOIN airport_aircraft AS T2 ON T1.Aircraft_ID = T2.Aircraft_ID JOIN airport AS T3 ON T2.Airport_ID = T3.Airport_ID WHERE T3.Total_Passengers > 10000000 [/SQL]


Question: What is the average total number of passengers of airports that are associated with aircraft "Robinson R-22"?

Context: CREATE TABLE airport (Total_Passengers INTEGER, Airport_ID VARCHAR); CREATE TABLE aircraft (Aircraft_ID VARCHAR, Aircraft VARCHAR); CREATE TABLE airport_aircraft (Aircraft_ID VARCHAR, Airport_ID VARCHAR)

Answer: [SQL] SELECT AVG(T3.Total_Passengers) FROM aircraft AS T1 JOIN airport_aircraft AS T2 ON T1.Aircraft_ID = T2.Aircraft_ID JOIN airport AS T3 ON T2.Airport_ID = T3.Airport_ID WHERE T1.Aircraft = "Robinson R-22" [/SQL]


Question: Please list the location and the winning aircraft name.

Context: CREATE TABLE MATCH (Location VARCHAR, Winning_Aircraft VARCHAR); CREATE TABLE aircraft (Aircraft VARCHAR, Aircraft_ID VARCHAR)

Answer: [SQL] SELECT T2.Location, T1.Aircraft FROM aircraft AS T1 JOIN MATCH AS T2 ON T1.Aircraft_ID = T2.Winning_Aircraft [/SQL]


Question: List the name of the aircraft that has been named winning aircraft the most number of times.

Context: CREATE TABLE MATCH (Winning_Aircraft VARCHAR); CREATE TABLE aircraft (Aircraft VARCHAR, Aircraft_ID VARCHAR)

Answer: [SQL] SELECT T1.Aircraft FROM aircraft AS T1 JOIN MATCH AS T2 ON T1.Aircraft_ID = T2.Winning_Aircraft GROUP BY T2.Winning_Aircraft ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: List the names of aircrafts and the number of times it won matches.

Answer: [SQL] SELECT T1.Aircraft, COUNT(*) FROM aircraft AS T1 JOIN MATCH AS T2 ON T1.Aircraft_ID = T2.Winning_Aircraft GROUP BY T2.Winning_Aircraft [/SQL]


Question: List names of all pilot in descending order of age.

Answer: [SQL] SELECT Name FROM pilot ORDER BY Age DESC [/SQL]


Question: List the names of aircrafts and that won matches at least twice.

Answer: [SQL] SELECT T1.Aircraft FROM aircraft AS T1 JOIN MATCH AS T2 ON T1.Aircraft_ID = T2.Winning_Aircraft GROUP BY T2.Winning_Aircraft HAVING COUNT(*) >= 2 [/SQL]


Question: List the names of aircrafts and that did not win any match.

Context: CREATE TABLE aircraft (Aircraft VARCHAR, Aircraft_ID VARCHAR, Winning_Aircraft VARCHAR); CREATE TABLE MATCH (Aircraft VARCHAR, Aircraft_ID VARCHAR, Winning_Aircraft VARCHAR)

Answer: [SQL] SELECT Aircraft FROM aircraft WHERE NOT Aircraft_ID IN (SELECT Winning_Aircraft FROM MATCH) [/SQL]


Question: Show the names of aircrafts that are associated with both an airport named "London Heathrow" and an airport named "London Gatwick"

Answer: [SQL] SELECT T1.Aircraft FROM aircraft AS T1 JOIN airport_aircraft AS T2 ON T1.Aircraft_ID = T2.Aircraft_ID JOIN airport AS T3 ON T2.Airport_ID = T3.Airport_ID WHERE T3.Airport_Name = "London Heathrow" INTERSECT SELECT T1.Aircraft FROM aircraft AS T1 JOIN airport_aircraft AS T2 ON T1.Aircraft_ID = T2.Aircraft_ID JOIN airport AS T3 ON T2.Airport_ID = T3.Airport_ID WHERE T3.Airport_Name = "London Gatwick" [/SQL]


Question: Show all information on the airport that has the largest number of international passengers.

Context: CREATE TABLE airport (International_Passengers VARCHAR)

Answer: [SQL] SELECT * FROM airport ORDER BY International_Passengers DESC LIMIT 1 [/SQL]


Question: find the name and age of the pilot who has won the most number of times among the pilots who are younger than 30.

Context: CREATE TABLE MATCH (winning_pilot VARCHAR); CREATE TABLE pilot (name VARCHAR, age INTEGER, pilot_id VARCHAR)

Answer: [SQL] SELECT t1.name, t1.age FROM pilot AS t1 JOIN MATCH AS t2 ON t1.pilot_id = t2.winning_pilot WHERE t1.age < 30 GROUP BY t2.winning_pilot ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: what is the name and age of the youngest winning pilot?

Context: CREATE TABLE pilot (name VARCHAR, age VARCHAR, pilot_id VARCHAR); CREATE TABLE MATCH (winning_pilot VARCHAR)

Answer: [SQL] SELECT t1.name, t1.age FROM pilot AS t1 JOIN MATCH AS t2 ON t1.pilot_id = t2.winning_pilot ORDER BY t1.age LIMIT 1 [/SQL]


Question: find the name of pilots who did not win the matches held in the country of Australia.

Context: CREATE TABLE MATCH (name VARCHAR, pilot_id VARCHAR, Winning_Pilot VARCHAR, country VARCHAR); CREATE TABLE pilot (name VARCHAR, pilot_id VARCHAR, Winning_Pilot VARCHAR, country VARCHAR)

Answer: [SQL] SELECT name FROM pilot WHERE NOT pilot_id IN (SELECT Winning_Pilot FROM MATCH WHERE country = 'Australia') [/SQL]


Question: How many residents does each property have? List property id and resident count.

Context: CREATE TABLE properties (property_id VARCHAR); CREATE TABLE residents (property_id VARCHAR)

Answer: [SQL] SELECT T1.property_id, COUNT(*) FROM properties AS T1 JOIN residents AS T2 ON T1.property_id = T2.property_id GROUP BY T1.property_id [/SQL]


Question: What is the distinct service types that are provided by the organization which has detail 'Denesik and Sons Party'?

Context: CREATE TABLE services (service_type_code VARCHAR, organization_id VARCHAR); CREATE TABLE organizations (organization_id VARCHAR, organization_details VARCHAR)

Answer: [SQL] SELECT DISTINCT T1.service_type_code FROM services AS T1 JOIN organizations AS T2 ON T1.organization_id = T2.organization_id WHERE T2.organization_details = 'Denesik and Sons Party' [/SQL]


Question: How many services has each resident requested? List the resident id, details, and the count in descending order of the count.

Context: CREATE TABLE Residents_Services (resident_id VARCHAR); CREATE TABLE Residents (resident_id VARCHAR, other_details VARCHAR)

Answer: [SQL] SELECT T1.resident_id, T1.other_details, COUNT(*) FROM Residents AS T1 JOIN Residents_Services AS T2 ON T1.resident_id = T2.resident_id GROUP BY T1.resident_id ORDER BY COUNT(*) DESC [/SQL]


Question: What is the maximum number that a certain service is provided? List the service id, details and number.

Context: CREATE TABLE Services (service_id VARCHAR, service_details VARCHAR); CREATE TABLE Residents_Services (service_id VARCHAR)

Answer: [SQL] SELECT T1.service_id, T1.service_details, COUNT(*) FROM Services AS T1 JOIN Residents_Services AS T2 ON T1.service_id = T2.service_id GROUP BY T1.service_id ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: List the id and type of each thing, and the details of the organization that owns it.

Context: CREATE TABLE Organizations (organization_details VARCHAR, organization_id VARCHAR); CREATE TABLE Things (thing_id VARCHAR, type_of_Thing_Code VARCHAR, organization_id VARCHAR)

Answer: [SQL] SELECT T1.thing_id, T1.type_of_Thing_Code, T2.organization_details FROM Things AS T1 JOIN Organizations AS T2 ON T1.organization_id = T2.organization_id [/SQL]


Question: What are the id and details of the customers who have at least 3 events?

Context: CREATE TABLE Customers (customer_id VARCHAR, customer_details VARCHAR); CREATE TABLE Customer_Events (customer_id VARCHAR)

Answer: [SQL] SELECT T1.customer_id, T1.customer_details FROM Customers AS T1 JOIN Customer_Events AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id HAVING COUNT(*) >= 3 [/SQL]


Question: What is each customer's move in date, and the corresponding customer id and details?

Context: CREATE TABLE Customer_Events (date_moved_in VARCHAR, customer_id VARCHAR); CREATE TABLE Customers (customer_id VARCHAR, customer_details VARCHAR)

Answer: [SQL] SELECT T2.date_moved_in, T1.customer_id, T1.customer_details FROM Customers AS T1 JOIN Customer_Events AS T2 ON T1.customer_id = T2.customer_id [/SQL]


Question: Which events have the number of notes between one and three? List the event id and the property id.

Context: CREATE TABLE Customer_Events (Customer_Event_ID VARCHAR, property_id VARCHAR, customer_event_id VARCHAR); CREATE TABLE Customer_Event_Notes (Customer_Event_ID VARCHAR)

Answer: [SQL] SELECT T1.Customer_Event_ID, T1.property_id FROM Customer_Events AS T1 JOIN Customer_Event_Notes AS T2 ON T1.Customer_Event_ID = T2.Customer_Event_ID GROUP BY T1.customer_event_id HAVING COUNT(*) BETWEEN 1 AND 3 [/SQL]


Question: What are the distinct id and type of the thing that has the status 'Close' or has a status record before the date '2017-06-19 02:59:21'

Context: CREATE TABLE Timed_Status_of_Things (thing_id VARCHAR, Status_of_Thing_Code VARCHAR, Date_and_Date VARCHAR); CREATE TABLE Things (thing_id VARCHAR, Type_of_Thing_Code VARCHAR)

Answer: [SQL] SELECT DISTINCT T2.thing_id, T2.Type_of_Thing_Code FROM Timed_Status_of_Things AS T1 JOIN Things AS T2 ON T1.thing_id = T2.thing_id WHERE T1.Status_of_Thing_Code = 'Close' OR T1.Date_and_Date < '2017-06-19 02:59:21' [/SQL]


Question: How many distinct locations have the things with service detail 'Unsatisfied' been located in?

Context: CREATE TABLE Timed_Locations_of_Things (Location_Code VARCHAR, thing_id VARCHAR); CREATE TABLE Things (thing_id VARCHAR, service_details VARCHAR)

Answer: [SQL] SELECT COUNT(DISTINCT T2.Location_Code) FROM Things AS T1 JOIN Timed_Locations_of_Things AS T2 ON T1.thing_id = T2.thing_id WHERE T1.service_details = 'Unsatisfied' [/SQL]


Question: How many different status codes of things are there?

Context: CREATE TABLE Timed_Status_of_Things (Status_of_Thing_Code VARCHAR)

Answer: [SQL] SELECT COUNT(DISTINCT Status_of_Thing_Code) FROM Timed_Status_of_Things [/SQL]


Question: Which organizations are not a parent organization of others? List the organization id.

Context: CREATE TABLE organizations (organization_id VARCHAR, parent_organization_id VARCHAR)

Answer: [SQL] SELECT organization_id FROM organizations EXCEPT SELECT parent_organization_id FROM organizations [/SQL]


Question: When is the last day any resident moved in?

Context: CREATE TABLE Residents (date_moved_in INTEGER)

Answer: [SQL] SELECT MAX(date_moved_in) FROM Residents [/SQL]


Question: What are the resident details containing the substring 'Miss'?

Context: CREATE TABLE Residents (other_details VARCHAR)

Answer: [SQL] SELECT other_details FROM Residents WHERE other_details LIKE '%Miss%' [/SQL]


Question: List the customer event id and the corresponding move in date and property id.

Context: CREATE TABLE customer_events (customer_event_id VARCHAR, date_moved_in VARCHAR, property_id VARCHAR)

Answer: [SQL] SELECT customer_event_id, date_moved_in, property_id FROM customer_events [/SQL]


Question: How many customers did not have any event?

Context: CREATE TABLE customers (customer_id VARCHAR); CREATE TABLE customer_events (customer_id VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM customers WHERE NOT customer_id IN (SELECT customer_id FROM customer_events) [/SQL]


Question: What are the distinct move in dates of the residents?

Context: CREATE TABLE residents (date_moved_in VARCHAR)

Answer: [SQL] SELECT DISTINCT date_moved_in FROM residents [/SQL]


Question: List the locations of schools in ascending order of enrollment.

Context: CREATE TABLE school (LOCATION VARCHAR, Enrollment VARCHAR)

Answer: [SQL] SELECT LOCATION FROM school ORDER BY Enrollment [/SQL]


Question: List the locations of schools in descending order of founded year.

Context: CREATE TABLE school (LOCATION VARCHAR, Founded VARCHAR)

Answer: [SQL] SELECT LOCATION FROM school ORDER BY Founded DESC [/SQL]


Question: What are the enrollments of schools whose denomination is not "Catholic"?

Context: CREATE TABLE school (Enrollment VARCHAR, Denomination VARCHAR)

Answer: [SQL] SELECT Enrollment FROM school WHERE Denomination <> "Catholic" [/SQL]


Question: What is the average enrollment of schools?

Context: CREATE TABLE school (Enrollment INTEGER)

Answer: [SQL] SELECT AVG(Enrollment) FROM school [/SQL]


Question: What are the teams of the players, sorted in ascending alphabetical order?

Context: CREATE TABLE player (Team VARCHAR)

Answer: [SQL] SELECT Team FROM player ORDER BY Team [/SQL]


Question: Find the team of the player of the highest age.

Context: CREATE TABLE player (Team VARCHAR, Age VARCHAR)

Answer: [SQL] SELECT Team FROM player ORDER BY Age DESC LIMIT 1 [/SQL]


Question: List the teams of the players with the top 5 largest ages.

Answer: [SQL] SELECT Team FROM player ORDER BY Age DESC LIMIT 5 [/SQL]


Question: For each player, show the team and the location of school they belong to.

Context: CREATE TABLE school (Location VARCHAR, School_ID VARCHAR); CREATE TABLE player (Team VARCHAR, School_ID VARCHAR)

Answer: [SQL] SELECT T1.Team, T2.Location FROM player AS T1 JOIN school AS T2 ON T1.School_ID = T2.School_ID [/SQL]


Question: Show the locations of schools that have more than 1 player.

Context: CREATE TABLE player (School_ID VARCHAR); CREATE TABLE school (Location VARCHAR, School_ID VARCHAR)

Answer: [SQL] SELECT T2.Location FROM player AS T1 JOIN school AS T2 ON T1.School_ID = T2.School_ID GROUP BY T1.School_ID HAVING COUNT(*) > 1 [/SQL]


Question: Show the denomination of the school that has the most players.

Context: CREATE TABLE player (School_ID VARCHAR); CREATE TABLE school (Denomination VARCHAR, School_ID VARCHAR)

Answer: [SQL] SELECT T2.Denomination FROM player AS T1 JOIN school AS T2 ON T1.School_ID = T2.School_ID GROUP BY T1.School_ID ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: Show locations and nicknames of schools.

Context: CREATE TABLE school (Location VARCHAR, School_ID VARCHAR); CREATE TABLE school_details (Nickname VARCHAR, School_ID VARCHAR)

Answer: [SQL] SELECT T1.Location, T2.Nickname FROM school AS T1 JOIN school_details AS T2 ON T1.School_ID = T2.School_ID [/SQL]


Question: Please show different denominations and the corresponding number of schools.

Context: CREATE TABLE school (Denomination VARCHAR)

Answer: [SQL] SELECT Denomination, COUNT(*) FROM school GROUP BY Denomination [/SQL]


Question: Please show different denominations and the corresponding number of schools in descending order.

Answer: [SQL] SELECT Denomination, COUNT(*) FROM school GROUP BY Denomination ORDER BY COUNT(*) DESC [/SQL]


Question: List the school color of the school that has the largest enrollment.

Context: CREATE TABLE school (School_Colors VARCHAR, Enrollment VARCHAR)

Answer: [SQL] SELECT School_Colors FROM school ORDER BY Enrollment DESC LIMIT 1 [/SQL]


Question: List the locations of schools that do not have any player.

Context: CREATE TABLE school (LOCATION VARCHAR, School_ID VARCHAR); CREATE TABLE Player (LOCATION VARCHAR, School_ID VARCHAR)

Answer: [SQL] SELECT LOCATION FROM school WHERE NOT School_ID IN (SELECT School_ID FROM Player) [/SQL]


Question: Show the denomination shared by schools founded before 1890 and schools founded after 1900

Context: CREATE TABLE school (Denomination VARCHAR, Founded INTEGER)

Answer: [SQL] SELECT Denomination FROM school WHERE Founded < 1890 INTERSECT SELECT Denomination FROM school WHERE Founded > 1900 [/SQL]


Question: Show the nicknames of schools that are not in division 1.

Context: CREATE TABLE school_details (Nickname VARCHAR, Division VARCHAR)

Answer: [SQL] SELECT Nickname FROM school_details WHERE Division <> "Division 1" [/SQL]


Question: Show the denomination shared by more than one school.

Answer: [SQL] SELECT Denomination FROM school GROUP BY Denomination HAVING COUNT(*) > 1 [/SQL]


Question: Find all the distinct district names ordered by city area in descending.

Context: CREATE TABLE district (District_name VARCHAR, city_area VARCHAR)

Answer: [SQL] SELECT DISTINCT District_name FROM district ORDER BY city_area DESC [/SQL]


Question: Find the list of page size which have more than 3 product listed

Context: CREATE TABLE product (max_page_size VARCHAR)

Answer: [SQL] SELECT max_page_size FROM product GROUP BY max_page_size HAVING COUNT(*) > 3 [/SQL]


Question: Find the name and population of district with population between 200000 and 2000000

Context: CREATE TABLE district (District_name VARCHAR, City_Population INTEGER)

Answer: [SQL] SELECT District_name, City_Population FROM district WHERE City_Population BETWEEN 200000 AND 2000000 [/SQL]


Question: Find the name all districts with city area greater than 10 or population larger than 100000

Context: CREATE TABLE district (district_name VARCHAR, city_area VARCHAR, City_Population VARCHAR)

Answer: [SQL] SELECT district_name FROM district WHERE city_area > 10 OR City_Population > 100000 [/SQL]


Question: Which district has the largest population?

Context: CREATE TABLE district (district_name VARCHAR, city_population VARCHAR)

Answer: [SQL] SELECT district_name FROM district ORDER BY city_population DESC LIMIT 1 [/SQL]


Question: Which district has the least area?

Context: CREATE TABLE district (district_name VARCHAR, city_area VARCHAR)

Answer: [SQL] SELECT district_name FROM district ORDER BY city_area LIMIT 1 [/SQL]


Question: Find the total population of the top 3 districts with the largest area.

Context: CREATE TABLE district (city_population INTEGER, city_area VARCHAR)

Answer: [SQL] SELECT SUM(city_population) FROM district ORDER BY city_area DESC LIMIT 3 [/SQL]


Question: Find all types of store and number of them.

Context: CREATE TABLE store (TYPE VARCHAR)

Answer: [SQL] SELECT TYPE, COUNT(*) FROM store GROUP BY TYPE [/SQL]


Question: Find the names of all stores in Khanewal District.

Context: CREATE TABLE district (district_id VARCHAR, district_name VARCHAR); CREATE TABLE store_district (store_id VARCHAR, district_id VARCHAR); CREATE TABLE store (store_name VARCHAR, store_id VARCHAR)

Answer: [SQL] SELECT t1.store_name FROM store AS t1 JOIN store_district AS t2 ON t1.store_id = t2.store_id JOIN district AS t3 ON t2.district_id = t3.district_id WHERE t3.district_name = "Khanewal District" [/SQL]


Question: Find all the stores in the district with the most population.

Context: CREATE TABLE store_district (store_id VARCHAR); CREATE TABLE district (district_id VARCHAR, city_population VARCHAR); CREATE TABLE store (store_name VARCHAR, store_id VARCHAR)

Answer: [SQL] SELECT t1.store_name FROM store AS t1 JOIN store_district AS t2 ON t1.store_id = t2.store_id WHERE district_id = (SELECT district_id FROM district ORDER BY city_population DESC LIMIT 1) [/SQL]


Question: Which city is the headquarter of the store named "Blackville" in?

Context: CREATE TABLE store (store_id VARCHAR, store_name VARCHAR); CREATE TABLE district (headquartered_city VARCHAR, district_id VARCHAR); CREATE TABLE store_district (store_id VARCHAR, district_id VARCHAR)

Answer: [SQL] SELECT t3.headquartered_city FROM store AS t1 JOIN store_district AS t2 ON t1.store_id = t2.store_id JOIN district AS t3 ON t2.district_id = t3.district_id WHERE t1.store_name = "Blackville" [/SQL]


Question: Find the number of stores in each city.

Context: CREATE TABLE district (headquartered_city VARCHAR, district_id VARCHAR); CREATE TABLE store_district (store_id VARCHAR, district_id VARCHAR); CREATE TABLE store (store_id VARCHAR)

Answer: [SQL] SELECT t3.headquartered_city, COUNT(*) FROM store AS t1 JOIN store_district AS t2 ON t1.store_id = t2.store_id JOIN district AS t3 ON t2.district_id = t3.district_id GROUP BY t3.headquartered_city [/SQL]


Question: Find the city with the most number of stores.

Answer: [SQL] SELECT t3.headquartered_city FROM store AS t1 JOIN store_district AS t2 ON t1.store_id = t2.store_id JOIN district AS t3 ON t2.district_id = t3.district_id GROUP BY t3.headquartered_city ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: What is the average pages per minute color?

Context: CREATE TABLE product (pages_per_minute_color INTEGER)

Answer: [SQL] SELECT AVG(pages_per_minute_color) FROM product [/SQL]


Question: What products are available at store named "Miramichi"?

Context: CREATE TABLE store_product (product_id VARCHAR, store_id VARCHAR); CREATE TABLE store (store_id VARCHAR, store_name VARCHAR); CREATE TABLE product (product VARCHAR, product_id VARCHAR)

Answer: [SQL] SELECT t1.product FROM product AS t1 JOIN store_product AS t2 ON t1.product_id = t2.product_id JOIN store AS t3 ON t2.store_id = t3.store_id WHERE t3.store_name = "Miramichi" [/SQL]


Question: Find products with max page size as "A4" and pages per minute color smaller than 5.

Context: CREATE TABLE product (product VARCHAR, max_page_size VARCHAR, pages_per_minute_color VARCHAR)

Answer: [SQL] SELECT product FROM product WHERE max_page_size = "A4" AND pages_per_minute_color < 5 [/SQL]


Question: Find products with max page size as "A4" or pages per minute color smaller than 5.

Answer: [SQL] SELECT product FROM product WHERE max_page_size = "A4" OR pages_per_minute_color < 5 [/SQL]


Question: Find all the product whose name contains the word "Scanner".

Context: CREATE TABLE product (product VARCHAR)

Answer: [SQL] SELECT product FROM product WHERE product LIKE "%Scanner%" [/SQL]


Question: Find the most prominent max page size among all the products.

Answer: [SQL] SELECT max_page_size FROM product GROUP BY max_page_size ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: Find the name of the products that are not using the most frequently-used max page size.

Context: CREATE TABLE product (product VARCHAR, max_page_size VARCHAR)

Answer: [SQL] SELECT product FROM product WHERE product <> (SELECT max_page_size FROM product GROUP BY max_page_size ORDER BY COUNT(*) DESC LIMIT 1) [/SQL]


Question: Find the total population of the districts where the area is bigger than the average city area.

Context: CREATE TABLE district (city_population INTEGER, city_area INTEGER)

Answer: [SQL] SELECT SUM(city_population) FROM district WHERE city_area > (SELECT AVG(city_area) FROM district) [/SQL]


Question: Find the names of districts where have both city mall and village store type stores.

Context: CREATE TABLE district (District_name VARCHAR, district_id VARCHAR); CREATE TABLE store (store_id VARCHAR, Type VARCHAR); CREATE TABLE store_district (store_id VARCHAR, district_id VARCHAR)

Answer: [SQL] SELECT t3.District_name FROM store AS t1 JOIN store_district AS t2 ON t1.store_id = t2.store_id JOIN district AS t3 ON t2.district_id = t3.district_id WHERE t1.Type = "City Mall" INTERSECT SELECT t3.District_name FROM store AS t1 JOIN store_district AS t2 ON t1.store_id = t2.store_id JOIN district AS t3 ON t2.district_id = t3.district_id WHERE t1.Type = "Village Store" [/SQL]


Question: What is the total enrollment number of all colleges?

Context: CREATE TABLE College (enr INTEGER)

Answer: [SQL] SELECT SUM(enr) FROM College [/SQL]


Question: What is the average enrollment number?

Context: CREATE TABLE College (enr INTEGER)

Answer: [SQL] SELECT AVG(enr) FROM College [/SQL]


Question: How many colleges in total?

Context: CREATE TABLE College (Id VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM College [/SQL]


Question: How many players have more than 1000 hours of training?

Context: CREATE TABLE Player (HS INTEGER)

Answer: [SQL] SELECT COUNT(*) FROM Player WHERE HS > 1000 [/SQL]


Question: How many colleges has more than 15000 students?

Context: CREATE TABLE College (enr INTEGER)

Answer: [SQL] SELECT COUNT(*) FROM College WHERE enr > 15000 [/SQL]


Question: What is the average training hours of all players?

Context: CREATE TABLE Player (HS INTEGER)

Answer: [SQL] SELECT AVG(HS) FROM Player [/SQL]


Question: Find the name and training hours of players whose hours are below 1500.

Context: CREATE TABLE Player (pName VARCHAR, HS INTEGER)

Answer: [SQL] SELECT pName, HS FROM Player WHERE HS < 1500 [/SQL]


Question: How many different colleges do attend the tryout test?

Context: CREATE TABLE tryout (cName VARCHAR)

Answer: [SQL] SELECT COUNT(DISTINCT cName) FROM tryout [/SQL]


Question: What are the unique types of player positions in the tryout?

Context: CREATE TABLE tryout (pPos VARCHAR)

Answer: [SQL] SELECT COUNT(DISTINCT pPos) FROM tryout [/SQL]


Question: How many students got accepted after the tryout?

Context: CREATE TABLE tryout (decision VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM tryout WHERE decision = 'yes' [/SQL]


Question: How many students whose are playing the role of goalie?

Context: CREATE TABLE tryout (pPos VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM tryout WHERE pPos = 'goalie' [/SQL]


Question: Find the max, average and min training hours of all players.

Context: CREATE TABLE Player (HS INTEGER)

Answer: [SQL] SELECT AVG(HS), MAX(HS), MIN(HS) FROM Player [/SQL]


Question: What is average enrollment of colleges in the state FL?

Context: CREATE TABLE College (enr INTEGER, state VARCHAR)

Answer: [SQL] SELECT AVG(enr) FROM College WHERE state = 'FL' [/SQL]


Question: What are the names of players whose training hours is between 500 and 1500?

Answer: [SQL] SELECT pName FROM Player WHERE HS BETWEEN 500 AND 1500 [/SQL]


Question: Find the players whose names contain letter 'a'.

Context: CREATE TABLE Player (pName VARCHAR)

Answer: [SQL] SELECT DISTINCT pName FROM Player WHERE pName LIKE '%a%' [/SQL]


Question: Find the name, enrollment of the colleges whose size is bigger than 10000 and location is in state LA.

Context: CREATE TABLE College (cName VARCHAR, enr VARCHAR, state VARCHAR)

Answer: [SQL] SELECT cName, enr FROM College WHERE enr > 10000 AND state = "LA" [/SQL]


Question: List all information about college sorted by enrollment number in the ascending order.

Context: CREATE TABLE College (enr VARCHAR)

Answer: [SQL] SELECT * FROM College ORDER BY enr [/SQL]


Question: List the name of the colleges whose enrollment is greater 18000 sorted by the college's name.

Context: CREATE TABLE College (cName VARCHAR, enr INTEGER)

Answer: [SQL] SELECT cName FROM College WHERE enr > 18000 ORDER BY cName [/SQL]


Question: Find the name of players whose card is yes in the descending order of training hours.

Context: CREATE TABLE Player (pName VARCHAR, yCard VARCHAR, HS VARCHAR)

Answer: [SQL] SELECT pName FROM Player WHERE yCard = 'yes' ORDER BY HS DESC [/SQL]


Question: Find the name of different colleges involved in the tryout in alphabetical order.

Context: CREATE TABLE tryout (cName VARCHAR)

Answer: [SQL] SELECT DISTINCT cName FROM tryout ORDER BY cName [/SQL]


Question: Which position is most popular among players in the tryout?

Context: CREATE TABLE tryout (pPos VARCHAR)

Answer: [SQL] SELECT pPos FROM tryout GROUP BY pPos ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: Find the number of students who participate in the tryout for each college ordered by descending count.

Context: CREATE TABLE tryout (cName VARCHAR)

Answer: [SQL] SELECT COUNT(*), cName FROM tryout GROUP BY cName ORDER BY COUNT(*) DESC [/SQL]


Question: What is minimum hours of the students playing in different position?

Context: CREATE TABLE player (HS INTEGER, pID VARCHAR); CREATE TABLE tryout (pPos VARCHAR, pID VARCHAR)

Answer: [SQL] SELECT MIN(T2.HS), T1.pPos FROM tryout AS T1 JOIN player AS T2 ON T1.pID = T2.pID GROUP BY T1.pPos [/SQL]


Question: What are the names of schools with the top 3 largest size?

Context: CREATE TABLE college (cName VARCHAR, enr VARCHAR)

Answer: [SQL] SELECT cName FROM college ORDER BY enr DESC LIMIT 3 [/SQL]


Question: What is the name of school that has the smallest enrollment in each state?

Context: CREATE TABLE college (cName VARCHAR, state VARCHAR, enr INTEGER)

Answer: [SQL] SELECT cName, state, MIN(enr) FROM college GROUP BY state [/SQL]


Question: Find the states where have some college students in tryout.

Context: CREATE TABLE college (cName VARCHAR); CREATE TABLE tryout (cName VARCHAR)

Answer: [SQL] SELECT DISTINCT state FROM college AS T1 JOIN tryout AS T2 ON T1.cName = T2.cName [/SQL]


Question: Find the states where have some college students in tryout and their decisions are yes.

Context: CREATE TABLE tryout (cName VARCHAR, decision VARCHAR); CREATE TABLE college (state VARCHAR, cName VARCHAR)

Answer: [SQL] SELECT DISTINCT T1.state FROM college AS T1 JOIN tryout AS T2 ON T1.cName = T2.cName WHERE T2.decision = 'yes' [/SQL]


Question: Find the name and college of students whose decisions are yes in the tryout.

Context: CREATE TABLE tryout (cName VARCHAR, pID VARCHAR, decision VARCHAR); CREATE TABLE player (pName VARCHAR, pID VARCHAR)

Answer: [SQL] SELECT T1.pName, T2.cName FROM player AS T1 JOIN tryout AS T2 ON T1.pID = T2.pID WHERE T2.decision = 'yes' [/SQL]


Question: Find the name of all students who were in the tryout sorted in alphabetic order.

Context: CREATE TABLE tryout (pID VARCHAR); CREATE TABLE player (pName VARCHAR, pID VARCHAR)

Answer: [SQL] SELECT T1.pName FROM player AS T1 JOIN tryout AS T2 ON T1.pID = T2.pID ORDER BY T1.pName [/SQL]


Question: Find the name and hours of the students whose tryout decision is yes.

Context: CREATE TABLE player (pName VARCHAR, HS VARCHAR, pID VARCHAR); CREATE TABLE tryout (pID VARCHAR, decision VARCHAR)

Answer: [SQL] SELECT T1.pName, T1.HS FROM player AS T1 JOIN tryout AS T2 ON T1.pID = T2.pID WHERE T2.decision = 'yes' [/SQL]


Question: Find the states of the colleges that have students in the tryout who played in striker position.

Context: CREATE TABLE tryout (cName VARCHAR, pPos VARCHAR); CREATE TABLE college (state VARCHAR, cName VARCHAR)

Answer: [SQL] SELECT T1.state FROM college AS T1 JOIN tryout AS T2 ON T1.cName = T2.cName WHERE T2.pPos = 'striker' [/SQL]


Question: Find the names of the students who are in the position of striker and got a yes tryout decision.

Context: CREATE TABLE tryout (pID VARCHAR, decision VARCHAR, pPos VARCHAR); CREATE TABLE player (pName VARCHAR, pID VARCHAR)

Answer: [SQL] SELECT T1.pName FROM player AS T1 JOIN tryout AS T2 ON T1.pID = T2.pID WHERE T2.decision = 'yes' AND T2.pPos = 'striker' [/SQL]


Question: Find the state of the college which player Charles is attending.

Context: CREATE TABLE tryout (cName VARCHAR, pID VARCHAR); CREATE TABLE player (pID VARCHAR, pName VARCHAR); CREATE TABLE college (state VARCHAR, cName VARCHAR)

Answer: [SQL] SELECT T1.state FROM college AS T1 JOIN tryout AS T2 ON T1.cName = T2.cName JOIN player AS T3 ON T2.pID = T3.pID WHERE T3.pName = 'Charles' [/SQL]


Question: Find the average and maximum hours for the students whose tryout decision is yes.

Context: CREATE TABLE player (HS INTEGER, pID VARCHAR); CREATE TABLE tryout (pID VARCHAR, decision VARCHAR)

Answer: [SQL] SELECT AVG(T1.HS), MAX(T1.HS) FROM player AS T1 JOIN tryout AS T2 ON T1.pID = T2.pID WHERE T2.decision = 'yes' [/SQL]


Question: Find the average hours for the students whose tryout decision is no.

Answer: [SQL] SELECT AVG(T1.HS) FROM player AS T1 JOIN tryout AS T2 ON T1.pID = T2.pID WHERE T2.decision = 'no' [/SQL]


Question: What is the maximum training hours for the students whose training hours is greater than 1000 in different positions?

Answer: [SQL] SELECT MAX(T1.HS), pPos FROM player AS T1 JOIN tryout AS T2 ON T1.pID = T2.pID WHERE T1.HS > 1000 GROUP BY T2.pPos [/SQL]


Question: Which colleges do the tryout players whose name starts with letter D go to?

Context: CREATE TABLE tryout (cName VARCHAR, pID VARCHAR); CREATE TABLE player (pID VARCHAR, pName VARCHAR)

Answer: [SQL] SELECT T1.cName FROM tryout AS T1 JOIN player AS T2 ON T1.pID = T2.pID WHERE T2.pName LIKE 'D%' [/SQL]


Question: Which college has any student who is a goalie and succeeded in the tryout.

Context: CREATE TABLE tryout (cName VARCHAR, decision VARCHAR, pPos VARCHAR)

Answer: [SQL] SELECT cName FROM tryout WHERE decision = 'yes' AND pPos = 'goalie' [/SQL]


Question: Find the name of the tryout players who are from the college with largest size.

Context: CREATE TABLE college (cName VARCHAR, enr VARCHAR); CREATE TABLE tryout (pID VARCHAR, cName VARCHAR); CREATE TABLE player (pName VARCHAR, pID VARCHAR)

Answer: [SQL] SELECT T2.pName FROM tryout AS T1 JOIN player AS T2 ON T1.pID = T2.pID WHERE T1.cName = (SELECT cName FROM college ORDER BY enr DESC LIMIT 1) [/SQL]


Question: What is the state and enrollment of the colleges where have any students who got accepted in the tryout decision.

Context: CREATE TABLE tryout (cName VARCHAR, decision VARCHAR); CREATE TABLE college (state VARCHAR, enr VARCHAR, cName VARCHAR)

Answer: [SQL] SELECT DISTINCT T1.state, T1.enr FROM college AS T1 JOIN tryout AS T2 ON T1.cName = T2.cName WHERE T2.decision = 'yes' [/SQL]


Question: Find the names of either colleges in LA with greater than 15000 size or in state AZ with less than 13000 enrollment.

Context: CREATE TABLE College (cName VARCHAR, enr VARCHAR, state VARCHAR)

Answer: [SQL] SELECT cName FROM College WHERE enr < 13000 AND state = "AZ" UNION SELECT cName FROM College WHERE enr > 15000 AND state = "LA" [/SQL]


Question: Find the names of schools that have some students playing in goalie and mid positions.

Context: CREATE TABLE tryout (cName VARCHAR, pPos VARCHAR)

Answer: [SQL] SELECT cName FROM tryout WHERE pPos = 'goalie' INTERSECT SELECT cName FROM tryout WHERE pPos = 'mid' [/SQL]


Question: Find the names of states that have some college students playing in goalie and mid positions.

Answer: [SQL] SELECT T1.state FROM college AS T1 JOIN tryout AS T2 ON T1.cName = T2.cName WHERE T2.pPos = 'goalie' INTERSECT SELECT T1.state FROM college AS T1 JOIN tryout AS T2 ON T1.cName = T2.cName WHERE T2.pPos = 'mid' [/SQL]


Question: How many schools have some students playing in goalie and mid positions.

Answer: [SQL] SELECT COUNT(*) FROM (SELECT cName FROM tryout WHERE pPos = 'goalie' INTERSECT SELECT cName FROM tryout WHERE pPos = 'mid') [/SQL]


Question: Find the names of schools that have some players in the mid position but not in the goalie position.

Answer: [SQL] SELECT cName FROM tryout WHERE pPos = 'mid' EXCEPT SELECT cName FROM tryout WHERE pPos = 'goalie' [/SQL]


Question: Find the names of states that have some college students playing in the mid position but not in the goalie position.

Answer: [SQL] SELECT T1.state FROM college AS T1 JOIN tryout AS T2 ON T1.cName = T2.cName WHERE T2.pPos = 'mid' EXCEPT SELECT T1.state FROM college AS T1 JOIN tryout AS T2 ON T1.cName = T2.cName WHERE T2.pPos = 'goalie' [/SQL]


Question: How many states that have some college students playing in the mid position but not in the goalie position.

Answer: [SQL] SELECT COUNT(*) FROM (SELECT T1.state FROM college AS T1 JOIN tryout AS T2 ON T1.cName = T2.cName WHERE T2.pPos = 'mid' EXCEPT SELECT T1.state FROM college AS T1 JOIN tryout AS T2 ON T1.cName = T2.cName WHERE T2.pPos = 'goalie') [/SQL]


Question: Find the states where have the colleges whose enrollments are less than the largest size.

Context: CREATE TABLE college (state VARCHAR, enr INTEGER)

Answer: [SQL] SELECT DISTINCT state FROM college WHERE enr < (SELECT MAX(enr) FROM college) [/SQL]


Question: Find names of colleges with enrollment greater than that of some (at least one) college in the FL state.

Context: CREATE TABLE college (cName VARCHAR, enr INTEGER, state VARCHAR)

Answer: [SQL] SELECT DISTINCT cName FROM college WHERE enr > (SELECT MIN(enr) FROM college WHERE state = 'FL') [/SQL]


Question: Find names of all colleges whose enrollment is greater than that of all colleges in the FL state.

Answer: [SQL] SELECT cName FROM college WHERE enr > (SELECT MAX(enr) FROM college WHERE state = 'FL') [/SQL]


Question: What is the total number of enrollment of schools that do not have any goalie player?

Context: CREATE TABLE college (enr INTEGER, cName VARCHAR, pPos VARCHAR); CREATE TABLE tryout (enr INTEGER, cName VARCHAR, pPos VARCHAR)

Answer: [SQL] SELECT SUM(enr) FROM college WHERE NOT cName IN (SELECT cName FROM tryout WHERE pPos = "goalie") [/SQL]


Question: What is the number of states that has some college whose enrollment is larger than the average enrollment?

Answer: [SQL] SELECT COUNT(DISTINCT state) FROM college WHERE enr > (SELECT AVG(enr) FROM college) [/SQL]


Question: What is the number of states that has some colleges whose enrollment is smaller than the average enrollment?

Answer: [SQL] SELECT COUNT(DISTINCT state) FROM college WHERE enr < (SELECT AVG(enr) FROM college) [/SQL]


Question: How many devices are there?

Context: CREATE TABLE device (Id VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM device [/SQL]


Question: List the carriers of devices in ascending alphabetical order.

Context: CREATE TABLE device (Carrier VARCHAR)

Answer: [SQL] SELECT Carrier FROM device ORDER BY Carrier [/SQL]


Question: What are the carriers of devices whose software platforms are not "Android"?

Context: CREATE TABLE device (Carrier VARCHAR, Software_Platform VARCHAR)

Answer: [SQL] SELECT Carrier FROM device WHERE Software_Platform <> 'Android' [/SQL]


Question: What are the names of shops in ascending order of open year?

Context: CREATE TABLE shop (Shop_Name VARCHAR, Open_Year VARCHAR)

Answer: [SQL] SELECT Shop_Name FROM shop ORDER BY Open_Year [/SQL]


Question: What is the average quantity of stocks?

Context: CREATE TABLE stock (Quantity INTEGER)

Answer: [SQL] SELECT AVG(Quantity) FROM stock [/SQL]


Question: What are the names and location of the shops in ascending alphabetical order of name.

Context: CREATE TABLE shop (Shop_Name VARCHAR, LOCATION VARCHAR)

Answer: [SQL] SELECT Shop_Name, LOCATION FROM shop ORDER BY Shop_Name [/SQL]


Question: How many different software platforms are there for devices?

Context: CREATE TABLE device (Software_Platform VARCHAR)

Answer: [SQL] SELECT COUNT(DISTINCT Software_Platform) FROM device [/SQL]


Question: List the open date of open year of the shop named "Apple".

Context: CREATE TABLE shop (Open_Date VARCHAR, Open_Year VARCHAR, Shop_Name VARCHAR)

Answer: [SQL] SELECT Open_Date, Open_Year FROM shop WHERE Shop_Name = "Apple" [/SQL]


Question: List the name of the shop with the latest open year.

Answer: [SQL] SELECT Shop_Name FROM shop ORDER BY Open_Year DESC LIMIT 1 [/SQL]


Question: Show names of shops and the carriers of devices they have in stock.

Context: CREATE TABLE shop (Shop_Name VARCHAR, Shop_ID VARCHAR); CREATE TABLE stock (Device_ID VARCHAR, Shop_ID VARCHAR); CREATE TABLE device (Carrier VARCHAR, Device_ID VARCHAR)

Answer: [SQL] SELECT T3.Shop_Name, T2.Carrier FROM stock AS T1 JOIN device AS T2 ON T1.Device_ID = T2.Device_ID JOIN shop AS T3 ON T1.Shop_ID = T3.Shop_ID [/SQL]


Question: Show names of shops that have more than one kind of device in stock.

Context: CREATE TABLE shop (Shop_Name VARCHAR, Shop_ID VARCHAR); CREATE TABLE stock (Shop_ID VARCHAR)

Answer: [SQL] SELECT T2.Shop_Name FROM stock AS T1 JOIN shop AS T2 ON T1.Shop_ID = T2.Shop_ID GROUP BY T1.Shop_ID HAVING COUNT(*) > 1 [/SQL]


Question: Show the name of the shop that has the most kind of devices in stock.

Answer: [SQL] SELECT T2.Shop_Name FROM stock AS T1 JOIN shop AS T2 ON T1.Shop_ID = T2.Shop_ID GROUP BY T1.Shop_ID ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: Show the name of the shop that have the largest quantity of devices in stock.

Context: CREATE TABLE stock (Shop_ID VARCHAR, quantity INTEGER); CREATE TABLE shop (Shop_Name VARCHAR, Shop_ID VARCHAR)

Answer: [SQL] SELECT T2.Shop_Name FROM stock AS T1 JOIN shop AS T2 ON T1.Shop_ID = T2.Shop_ID GROUP BY T1.Shop_ID ORDER BY SUM(T1.quantity) DESC LIMIT 1 [/SQL]


Question: Please show different software platforms and the corresponding number of devices using each.

Answer: [SQL] SELECT Software_Platform, COUNT(*) FROM device GROUP BY Software_Platform [/SQL]


Question: Please show the software platforms of devices in descending order of the count.

Answer: [SQL] SELECT Software_Platform FROM device GROUP BY Software_Platform ORDER BY COUNT(*) DESC [/SQL]


Question: List the software platform shared by the greatest number of devices.

Answer: [SQL] SELECT Software_Platform FROM device GROUP BY Software_Platform ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: List the names of shops that have no devices in stock.

Context: CREATE TABLE shop (Shop_Name VARCHAR, Shop_ID VARCHAR); CREATE TABLE stock (Shop_Name VARCHAR, Shop_ID VARCHAR)

Answer: [SQL] SELECT Shop_Name FROM shop WHERE NOT Shop_ID IN (SELECT Shop_ID FROM stock) [/SQL]


Question: Show the locations shared by shops with open year later than 2012 and shops with open year before 2008.

Context: CREATE TABLE shop (LOCATION VARCHAR, Open_Year INTEGER)

Answer: [SQL] SELECT LOCATION FROM shop WHERE Open_Year > 2012 INTERSECT SELECT LOCATION FROM shop WHERE Open_Year < 2008 [/SQL]


Question: List the carriers of devices that have no devices in stock.

Context: CREATE TABLE stock (Carrier VARCHAR, Device_ID VARCHAR); CREATE TABLE device (Carrier VARCHAR, Device_ID VARCHAR)

Answer: [SQL] SELECT Carrier FROM device WHERE NOT Device_ID IN (SELECT Device_ID FROM stock) [/SQL]


Question: Show the carriers of devices in stock at more than one shop.

Context: CREATE TABLE stock (Device_ID VARCHAR); CREATE TABLE device (Carrier VARCHAR, Device_ID VARCHAR)

Answer: [SQL] SELECT T2.Carrier FROM stock AS T1 JOIN device AS T2 ON T1.Device_ID = T2.Device_ID GROUP BY T1.Device_ID HAVING COUNT(*) > 1 [/SQL]


Question: How many bookings do we have?

Context: CREATE TABLE BOOKINGS (Id VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM BOOKINGS [/SQL]


Question: List the order dates of all the bookings.

Context: CREATE TABLE BOOKINGS (Order_Date VARCHAR)

Answer: [SQL] SELECT Order_Date FROM BOOKINGS [/SQL]


Question: Show all the planned delivery dates and actual delivery dates of bookings.

Context: CREATE TABLE BOOKINGS (Planned_Delivery_Date VARCHAR, Actual_Delivery_Date VARCHAR)

Answer: [SQL] SELECT Planned_Delivery_Date, Actual_Delivery_Date FROM BOOKINGS [/SQL]


Question: How many customers do we have?

Context: CREATE TABLE CUSTOMERS (Id VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM CUSTOMERS [/SQL]


Question: What are the phone and email for customer Harold?

Context: CREATE TABLE CUSTOMERS (Customer_Phone VARCHAR, Customer_Email_Address VARCHAR, Customer_Name VARCHAR)

Answer: [SQL] SELECT Customer_Phone, Customer_Email_Address FROM CUSTOMERS WHERE Customer_Name = "Harold" [/SQL]


Question: Show all the Store_Name of drama workshop groups.

Context: CREATE TABLE Drama_Workshop_Groups (Store_Name VARCHAR)

Answer: [SQL] SELECT Store_Name FROM Drama_Workshop_Groups [/SQL]


Question: Show the minimum, average, maximum order quantity of all invoices.

Context: CREATE TABLE INVOICES (Order_Quantity INTEGER)

Answer: [SQL] SELECT MIN(Order_Quantity), AVG(Order_Quantity), MAX(Order_Quantity) FROM INVOICES [/SQL]


Question: What are the distinct payment method codes in all the invoices?

Context: CREATE TABLE INVOICES (payment_method_code VARCHAR)

Answer: [SQL] SELECT DISTINCT payment_method_code FROM INVOICES [/SQL]


Question: What is the description of the marketing region China?

Context: CREATE TABLE Marketing_Regions (Marketing_Region_Descriptrion VARCHAR, Marketing_Region_Name VARCHAR)

Answer: [SQL] SELECT Marketing_Region_Descriptrion FROM Marketing_Regions WHERE Marketing_Region_Name = "China" [/SQL]


Question: Show all the distinct product names with price higher than the average.

Context: CREATE TABLE PRODUCTS (Product_Name VARCHAR, Product_Price INTEGER)

Answer: [SQL] SELECT DISTINCT Product_Name FROM PRODUCTS WHERE Product_Price > (SELECT AVG(Product_Price) FROM PRODUCTS) [/SQL]


Question: What is the name of the most expensive product?

Context: CREATE TABLE PRODUCTS (Product_Name VARCHAR, Product_Price VARCHAR)

Answer: [SQL] SELECT Product_Name FROM PRODUCTS ORDER BY Product_Price DESC LIMIT 1 [/SQL]


Question: What is the phone number of the performer Ashley?

Context: CREATE TABLE PERFORMERS (Customer_Phone VARCHAR, Customer_Name VARCHAR)

Answer: [SQL] SELECT Customer_Phone FROM PERFORMERS WHERE Customer_Name = "Ashley" [/SQL]


Question: Show all payment method codes and the number of orders for each code.

Answer: [SQL] SELECT payment_method_code, COUNT(*) FROM INVOICES GROUP BY payment_method_code [/SQL]


Question: What is the payment method code used by the most orders?

Answer: [SQL] SELECT payment_method_code FROM INVOICES GROUP BY payment_method_code ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: Which city is the address of the store named "FJA Filming" located in?

Context: CREATE TABLE Addresses (City_Town VARCHAR, Address_ID VARCHAR); CREATE TABLE Stores (Address_ID VARCHAR, Store_Name VARCHAR)

Answer: [SQL] SELECT T1.City_Town FROM Addresses AS T1 JOIN Stores AS T2 ON T1.Address_ID = T2.Address_ID WHERE T2.Store_Name = "FJA Filming" [/SQL]


Question: What are the states or counties of the address of the stores with marketing region code "CA"?

Context: CREATE TABLE Addresses (State_County VARCHAR, Address_ID VARCHAR); CREATE TABLE Stores (Address_ID VARCHAR, Marketing_Region_Code VARCHAR)

Answer: [SQL] SELECT T1.State_County FROM Addresses AS T1 JOIN Stores AS T2 ON T1.Address_ID = T2.Address_ID WHERE T2.Marketing_Region_Code = "CA" [/SQL]


Question: What is the name of the marketing region that the store Rob Dinning belongs to?

Context: CREATE TABLE Marketing_Regions (Marketing_Region_Name VARCHAR, Marketing_Region_Code VARCHAR); CREATE TABLE Stores (Marketing_Region_Code VARCHAR, Store_Name VARCHAR)

Answer: [SQL] SELECT T1.Marketing_Region_Name FROM Marketing_Regions AS T1 JOIN Stores AS T2 ON T1.Marketing_Region_Code = T2.Marketing_Region_Code WHERE T2.Store_Name = "Rob Dinning" [/SQL]


Question: What are the descriptions of the service types with product price above 100?

Context: CREATE TABLE Services (Service_Type_Code VARCHAR, Product_Price INTEGER); CREATE TABLE Ref_Service_Types (Service_Type_Description VARCHAR, Service_Type_Code VARCHAR)

Answer: [SQL] SELECT T1.Service_Type_Description FROM Ref_Service_Types AS T1 JOIN Services AS T2 ON T1.Service_Type_Code = T2.Service_Type_Code WHERE T2.Product_Price > 100 [/SQL]


Question: What is the description, code and the corresponding count of each service type?

Context: CREATE TABLE Services (Service_Type_Code VARCHAR); CREATE TABLE Ref_Service_Types (Service_Type_Description VARCHAR, Service_Type_Code VARCHAR)

Answer: [SQL] SELECT T1.Service_Type_Description, T2.Service_Type_Code, COUNT(*) FROM Ref_Service_Types AS T1 JOIN Services AS T2 ON T1.Service_Type_Code = T2.Service_Type_Code GROUP BY T2.Service_Type_Code [/SQL]


Question: What is the description and code of the type of service that is performed the most often?

Answer: [SQL] SELECT T1.Service_Type_Description, T1.Service_Type_Code FROM Ref_Service_Types AS T1 JOIN Services AS T2 ON T1.Service_Type_Code = T2.Service_Type_Code GROUP BY T1.Service_Type_Code ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: What are the phones and emails of workshop groups in which services are performed?

Context: CREATE TABLE Services (Workshop_Group_ID VARCHAR); CREATE TABLE Drama_Workshop_Groups (Store_Phone VARCHAR, Store_Email_Address VARCHAR, Workshop_Group_ID VARCHAR)

Answer: [SQL] SELECT T1.Store_Phone, T1.Store_Email_Address FROM Drama_Workshop_Groups AS T1 JOIN Services AS T2 ON T1.Workshop_Group_ID = T2.Workshop_Group_ID [/SQL]


Question: What are the names of workshop groups in which services with product name "film" are performed?

Context: CREATE TABLE Services (Workshop_Group_ID VARCHAR, Product_Name VARCHAR); CREATE TABLE Drama_Workshop_Groups (Store_Phone VARCHAR, Store_Email_Address VARCHAR, Workshop_Group_ID VARCHAR)

Answer: [SQL] SELECT T1.Store_Phone, T1.Store_Email_Address FROM Drama_Workshop_Groups AS T1 JOIN Services AS T2 ON T1.Workshop_Group_ID = T2.Workshop_Group_ID WHERE T2.Product_Name = "film" [/SQL]


Question: What are the different product names? What is the average product price for each of them?

Answer: [SQL] SELECT Product_Name, AVG(Product_Price) FROM PRODUCTS GROUP BY Product_Name [/SQL]


Question: What are the product names with average product price smaller than 1000000?

Answer: [SQL] SELECT Product_Name FROM PRODUCTS GROUP BY Product_Name HAVING AVG(Product_Price) < 1000000 [/SQL]


Question: What are the total order quantities of photo products?

Context: CREATE TABLE ORDER_ITEMS (Order_Quantity INTEGER, Product_ID VARCHAR); CREATE TABLE Products (Product_ID VARCHAR, Product_Name VARCHAR)

Answer: [SQL] SELECT SUM(T1.Order_Quantity) FROM ORDER_ITEMS AS T1 JOIN Products AS T2 ON T1.Product_ID = T2.Product_ID WHERE T2.Product_Name = "photo" [/SQL]


Question: What are the order details of the products with price higher than 2000?

Context: CREATE TABLE Products (Product_ID VARCHAR, Product_price INTEGER); CREATE TABLE ORDER_ITEMS (Other_Item_Details VARCHAR, Product_ID VARCHAR)

Answer: [SQL] SELECT T1.Other_Item_Details FROM ORDER_ITEMS AS T1 JOIN Products AS T2 ON T1.Product_ID = T2.Product_ID WHERE T2.Product_price > 2000 [/SQL]


Question: What are the actual delivery dates of orders with quantity 1?

Context: CREATE TABLE Customer_Orders (Actual_Delivery_Date VARCHAR, Order_ID VARCHAR); CREATE TABLE ORDER_ITEMS (Order_ID VARCHAR, Order_Quantity VARCHAR)

Answer: [SQL] SELECT T1.Actual_Delivery_Date FROM Customer_Orders AS T1 JOIN ORDER_ITEMS AS T2 ON T1.Order_ID = T2.Order_ID WHERE T2.Order_Quantity = 1 [/SQL]


Question: What are the order dates of orders with price higher than 1000?

Context: CREATE TABLE Products (Product_ID VARCHAR, Product_price INTEGER); CREATE TABLE ORDER_ITEMS (Order_ID VARCHAR, Product_ID VARCHAR); CREATE TABLE Customer_Orders (Order_Date VARCHAR, Order_ID VARCHAR)

Answer: [SQL] SELECT T1.Order_Date FROM Customer_Orders AS T1 JOIN ORDER_ITEMS AS T2 ON T1.Order_ID = T2.Order_ID JOIN Products AS T3 ON T2.Product_ID = T3.Product_ID WHERE T3.Product_price > 1000 [/SQL]


Question: How many distinct currency codes are there for all drama workshop groups?

Context: CREATE TABLE Drama_Workshop_Groups (Currency_Code VARCHAR)

Answer: [SQL] SELECT COUNT(DISTINCT Currency_Code) FROM Drama_Workshop_Groups [/SQL]


Question: What are the names of the drama workshop groups with address in Feliciaberg city?

Context: CREATE TABLE Addresses (Address_ID VARCHAR, City_Town VARCHAR); CREATE TABLE Drama_Workshop_Groups (Store_Name VARCHAR, Address_ID VARCHAR)

Answer: [SQL] SELECT T2.Store_Name FROM Addresses AS T1 JOIN Drama_Workshop_Groups AS T2 ON T1.Address_ID = T2.Address_ID WHERE T1.City_Town = "Feliciaberg" [/SQL]