cnatale/presto-athena-txt-2-sql huggingface dataset:
Show the names of artworks in ascending order of the year they are nominated in.
Additional table information: table: entertainment_awards
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 NULLS FIRST
Show the names of festivals that have nominated artworks of type 'Program Talent Show'.
Additional table information: table: entertainment_awards
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'
Show the ids and names of festivals that have at least two nominations for artworks.
Additional table information: table: entertainment_awards
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
Show the id, name of each festival and the number of artworks it has nominated.
Additional table information: table: entertainment_awards
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
Please show different types of artworks with the corresponding number of artworks of each type.
Additional table information: table: entertainment_awards
SQL: SELECT TYPE, COUNT(*) FROM artwork GROUP BY TYPE
List the most common type of artworks.
Additional table information: table: entertainment_awards
SQL: SELECT TYPE FROM artwork GROUP BY TYPE ORDER BY COUNT(*) DESC LIMIT 1
List the year in which there are more than one festivals.
Additional table information: table: entertainment_awards
SQL: SELECT YEAR FROM festival_detail GROUP BY YEAR HAVING COUNT(*) > 1
List the name of artworks that are not nominated.
Additional table information: table: entertainment_awards
SQL: SELECT Name FROM Artwork WHERE NOT Artwork_ID IN (SELECT Artwork_ID FROM nomination)
Show the number of audience in year 2008 or 2010.
Additional table information: table: entertainment_awards
SQL: SELECT Num_of_Audience FROM festival_detail WHERE YEAR = 2008 OR YEAR = 2010
What are the total number of the audiences who visited any of the festivals?
Additional table information: table: entertainment_awards
SQL: SELECT SUM(Num_of_Audience) FROM festival_detail
In which year are there festivals both inside the 'United States' and outside the 'United States'?
Additional table information: table: entertainment_awards
SQL: SELECT YEAR FROM festival_detail WHERE LOCATION = 'United States' INTERSECT SELECT YEAR FROM festival_detail WHERE LOCATION <> 'United States'
How many premises are there?
Additional table information: table: customers_campaigns_ecommerce
SQL: SELECT COUNT(*) FROM premises
What are all the distinct premise types?
Additional table information: table: customers_campaigns_ecommerce
SQL: SELECT DISTINCT premises_type FROM premises
Find the types and details for all premises and order by the premise type.
Additional table information: table: customers_campaigns_ecommerce
SQL: SELECT premises_type, premise_details FROM premises ORDER BY premises_type NULLS FIRST
Show each premise type and the number of premises in that type.
Additional table information: table: customers_campaigns_ecommerce
SQL: SELECT premises_type, COUNT(*) FROM premises GROUP BY premises_type
Show all distinct product categories along with the number of mailshots in each category.
Additional table information: table: customers_campaigns_ecommerce
SQL: SELECT product_category, COUNT(*) FROM mailshot_campaigns GROUP BY product_category
Show the name and phone of the customer without any mailshot.
Additional table information: table: customers_campaigns_ecommerce
SQL: SELECT customer_name, customer_phone FROM customers WHERE NOT customer_id IN (SELECT customer_id FROM mailshot_customers)
Show the name and phone for customers with a mailshot with outcome code 'No Response'.
Additional table information: table: customers_campaigns_ecommerce
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'
Show the outcome code of mailshots along with the number of mailshots in each outcome code.
Additional table information: table: customers_campaigns_ecommerce
SQL: SELECT outcome_code, COUNT(*) FROM mailshot_customers GROUP BY outcome_code
Show the names of customers who have at least 2 mailshots with outcome code 'Order'.
Additional table information: table: customers_campaigns_ecommerce
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
Show the names of customers who have the most mailshots.
Additional table information: table: customers_campaigns_ecommerce
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
What are the name and payment method of customers who have both mailshots in 'Order' outcome and mailshots in 'No Response' outcome.
Additional table information: table: customers_campaigns_ecommerce
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'
Show the premise type and address type code for all customer addresses.
Additional table information: table: customers_campaigns_ecommerce
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
What are the distinct address type codes for all customer addresses?
Additional table information: table: customers_campaigns_ecommerce
SQL: SELECT DISTINCT address_type_code FROM customer_addresses
Show the shipping charge and customer id for customer orders with order status Cancelled or Paid.
Additional table information: table: customers_campaigns_ecommerce
SQL: SELECT order_shipping_charges, customer_id FROM customer_orders WHERE order_status_code = 'Cancelled' OR order_status_code = 'Paid'
Show the names of customers having an order with shipping method FedEx and order status Paid.
Additional table information: table: customers_campaigns_ecommerce
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'
How many courses are there in total?
Additional table information: table: college_3
SQL: SELECT COUNT(*) FROM COURSE
Count the number of courses.
Additional table information: table: college_3
SQL: SELECT COUNT(*) FROM COURSE
How many courses have more than 2 credits?
Additional table information: table: college_3
SQL: SELECT COUNT(*) FROM COURSE WHERE Credits > 2
Count the number of courses with more than 2 credits.
Additional table information: table: college_3
SQL: SELECT COUNT(*) FROM COURSE WHERE Credits > 2
List all names of courses with 1 credit?
Additional table information: table: college_3
SQL: SELECT CName FROM COURSE WHERE Credits = 1
What are the names of courses with 1 credit?
Additional table information: table: college_3
SQL: SELECT CName FROM COURSE WHERE Credits = 1
Which courses are taught on days MTW?
Additional table information: table: college_3
SQL: SELECT CName FROM COURSE WHERE Days = 'MTW'
What are the course names for courses taught on MTW?
Additional table information: table: college_3
SQL: SELECT CName FROM COURSE WHERE Days = 'MTW'
What is the number of departments in Division 'AS'?
Additional table information: table: college_3
SQL: SELECT COUNT(*) FROM DEPARTMENT WHERE Division = 'AS'
How many departments are in the division AS?
Additional table information: table: college_3
SQL: SELECT COUNT(*) FROM DEPARTMENT WHERE Division = 'AS'
What are the phones of departments in Room 268?
Additional table information: table: college_3
SQL: SELECT DPhone FROM DEPARTMENT WHERE Room = 268
Give the phones for departments in room 268.
Additional table information: table: college_3
SQL: SELECT DPhone FROM DEPARTMENT WHERE Room = 268
Find the number of students that have at least one grade 'B'.
Additional table information: table: college_3
SQL: SELECT COUNT(DISTINCT StuID) FROM ENROLLED_IN WHERE Grade = 'B'
How many students have had at least one 'B' grade?
Additional table information: table: college_3
SQL: SELECT COUNT(DISTINCT StuID) FROM ENROLLED_IN WHERE Grade = 'B'
Find the max and min grade point for all letter grade.
Additional table information: table: college_3
SQL: SELECT MAX(gradepoint), MIN(gradepoint) FROM GRADECONVERSION
What are the maximum and minumum grade points?
Additional table information: table: college_3
SQL: SELECT MAX(gradepoint), MIN(gradepoint) FROM GRADECONVERSION
Find the first names of students whose first names contain letter 'a'.
Additional table information: table: college_3
SQL: SELECT DISTINCT Fname FROM STUDENT WHERE Fname LIKE '%a%'
What are the first names for students who have an 'a' in their first name?
Additional table information: table: college_3
SQL: SELECT DISTINCT Fname FROM STUDENT WHERE Fname LIKE '%a%'
Find the first names and last names of male (sex is M) faculties who live in building NEB.
Additional table information: table: college_3
SQL: SELECT Fname, Lname FROM FACULTY WHERE sex = 'M' AND Building = 'NEB'
What are the full names of faculties with sex M and who live in building NEB?
Additional table information: table: college_3
SQL: SELECT Fname, Lname FROM FACULTY WHERE sex = 'M' AND Building = 'NEB'
Find the rooms of faculties with rank professor who live in building NEB.
Additional table information: table: college_3
SQL: SELECT Room FROM FACULTY WHERE Rank = 'Professor' AND Building = 'NEB'
What are the rooms for members of the faculty who are professors and who live in building NEB?
Additional table information: table: college_3
SQL: SELECT Room FROM FACULTY WHERE Rank = 'Professor' AND Building = 'NEB'
Find the department name that is in Building 'Mergenthaler'.
Additional table information: table: college_3
SQL: SELECT DName FROM DEPARTMENT WHERE Building = 'Mergenthaler'
What is the name of the department in the Building Mergenthaler?
Additional table information: table: college_3
SQL: SELECT DName FROM DEPARTMENT WHERE Building = 'Mergenthaler'
List all information about courses sorted by credits in the ascending order.
Additional table information: table: college_3
SQL: SELECT * FROM COURSE ORDER BY Credits NULLS FIRST
What is all the information about courses, ordered by credits ascending?
Additional table information: table: college_3
SQL: SELECT * FROM COURSE ORDER BY Credits NULLS FIRST
List the course name of courses sorted by credits.
Additional table information: table: college_3
SQL: SELECT CName FROM COURSE ORDER BY Credits NULLS FIRST
What are the course names, ordered by credits?
Additional table information: table: college_3
SQL: SELECT CName FROM COURSE ORDER BY Credits NULLS FIRST
Find the first name of students in the descending order of age.
Additional table information: table: college_3
SQL: SELECT Fname FROM STUDENT ORDER BY Age DESC
What are the first names of students, ordered by age from greatest to least?
Additional table information: table: college_3
SQL: SELECT Fname FROM STUDENT ORDER BY Age DESC
Find the last name of female (sex is F) students in the descending order of age.
Additional table information: table: college_3
SQL: SELECT LName FROM STUDENT WHERE Sex = 'F' ORDER BY Age DESC
What are the last names of female students, ordered by age descending?
Additional table information: table: college_3
SQL: SELECT LName FROM STUDENT WHERE Sex = 'F' ORDER BY Age DESC
Find the last names of faculties in building Barton in alphabetic order.
Additional table information: table: college_3
SQL: SELECT Lname FROM FACULTY WHERE Building = 'Barton' ORDER BY Lname NULLS FIRST
What are the last names of faculty in building Barton, sorted by last name?
Additional table information: table: college_3
SQL: SELECT Lname FROM FACULTY WHERE Building = 'Barton' ORDER BY Lname NULLS FIRST
Find the first names of faculties of rank Professor in alphabetic order.
Additional table information: table: college_3
SQL: SELECT Fname FROM FACULTY WHERE Rank = 'Professor' ORDER BY Fname NULLS FIRST
What are the first names for all faculty professors, ordered by first name?
Additional table information: table: college_3
SQL: SELECT Fname FROM FACULTY WHERE Rank = 'Professor' ORDER BY Fname NULLS FIRST
Find the name of the department that has the biggest number of students minored in?
Additional table information: table: college_3
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
What is the name of the department with the most students minoring in it?
Additional table information: table: college_3
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
Find the name of the department that has no students minored in?
Additional table information: table: college_3
SQL: SELECT DName FROM DEPARTMENT EXCEPT SELECT T1.DName FROM DEPARTMENT AS T1 JOIN MINOR_IN AS T2 ON T1.DNO = T2.DNO
What is the name of the department htat has no students minoring in it?
Additional table information: table: college_3
SQL: SELECT DName FROM DEPARTMENT EXCEPT SELECT T1.DName FROM DEPARTMENT AS T1 JOIN MINOR_IN AS T2 ON T1.DNO = T2.DNO
Find the name of the department that has the fewest members.
Additional table information: table: college_3
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(*) ASC NULLS FIRST LIMIT 1
What is the name of the department with the fewest members?
Additional table information: table: college_3
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(*) ASC NULLS FIRST LIMIT 1
Find the rank of the faculty that the fewest faculties belong to.
Additional table information: table: college_3
SQL: SELECT Rank FROM FACULTY GROUP BY Rank ORDER BY COUNT(*) ASC NULLS FIRST LIMIT 1
What is the least common faculty rank?
Additional table information: table: college_3
SQL: SELECT Rank FROM FACULTY GROUP BY Rank ORDER BY COUNT(*) ASC NULLS FIRST LIMIT 1
What are the first and last names of the instructors who teach the top 3 number of courses?
Additional table information: table: college_3
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
What are the full names of the 3 instructors who teach the most courses?
Additional table information: table: college_3
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
Which building does the instructor who teaches the most number of courses live in?
Additional table information: table: college_3
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
Give the building that the instructor who teaches the greatest number of courses lives in.
Additional table information: table: college_3
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
What are the name of courses that have at least five enrollments?
Additional table information: table: college_3
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
Give the names of the courses with at least five enrollments.
Additional table information: table: college_3
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
Find the first name and last name of the instructor of course that has course name
Additional table information: table: college_3
SQL: SELECT T2.Fname, T2.Lname FROM COURSE AS T1 JOIN FACULTY AS T2 ON T1.Instructor = T2.FacID WHERE T1.CName = 'COMPUTER LITERACY'
What is the full name of the instructor who has a course named COMPUTER LITERACY?
Additional table information: table: college_3
SQL: SELECT T2.Fname, T2.Lname FROM COURSE AS T1 JOIN FACULTY AS T2 ON T1.Instructor = T2.FacID WHERE T1.CName = 'COMPUTER LITERACY'
Find the department name and room of the course INTRODUCTION TO COMPUTER SCIENCE.
Additional table information: table: college_3
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'
What are the department name and room for the course INTRODUCTION TO COMPUTER SCIENCE?
Additional table information: table: college_3
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'
Find the student first and last names and grade points of all enrollments.
Additional table information: table: college_3
SQL: SELECT T3.Fname, T3.LName, T2.gradepoint FROM ENROLLED_IN AS T1, GRADECONVERSION AS T2 JOIN STUDENT AS T3 ON T1.Grade = T2.lettergrade AND T1.StuID = T3.StuID
What are the full names and gradepoints for all enrollments?
Additional table information: table: college_3
SQL: SELECT T3.Fname, T3.LName, T2.gradepoint FROM ENROLLED_IN AS T1, GRADECONVERSION AS T2 JOIN STUDENT AS T3 ON T1.Grade = T2.lettergrade AND T1.StuID = T3.StuID
Find the distinct student first names of all students that have grade point at least 3.8 in one course.
Additional table information: table: college_3
SQL: SELECT DISTINCT T3.Fname FROM ENROLLED_IN AS T1, GRADECONVERSION AS T2 JOIN STUDENT AS T3 ON T1.Grade = T2.lettergrade AND T1.StuID = T3.StuID WHERE T2.gradepoint >= 3.8
What are the distinct first names for students with a grade point of 3.8 or above in at least one course?
Additional table information: table: college_3
SQL: SELECT DISTINCT T3.Fname FROM ENROLLED_IN AS T1, GRADECONVERSION AS T2 JOIN STUDENT AS T3 ON T1.Grade = T2.lettergrade AND T1.StuID = T3.StuID WHERE T2.gradepoint >= 3.8
Find the full names of faculties who are members of department with department number 520.
Additional table information: table: college_3
SQL: SELECT T1.Fname, T1.Lname FROM FACULTY AS T1 JOIN MEMBER_OF AS T2 ON T1.FacID = T2.FacID WHERE T2.DNO = 520
What are the full names of faculty members who are a part of department 520?
Additional table information: table: college_3
SQL: SELECT T1.Fname, T1.Lname FROM FACULTY AS T1 JOIN MEMBER_OF AS T2 ON T1.FacID = T2.FacID WHERE T2.DNO = 520
What are the first names and last names of the students that minor in the department with DNO 140.
Additional table information: table: college_3
SQL: SELECT T2.Fname, T2.Lname FROM MINOR_IN AS T1 JOIN STUDENT AS T2 ON T1.StuID = T2.StuID WHERE T1.DNO = 140
What are the full names of students minoring in department 140?
Additional table information: table: college_3
SQL: SELECT T2.Fname, T2.Lname FROM MINOR_IN AS T1 JOIN STUDENT AS T2 ON T1.StuID = T2.StuID WHERE T1.DNO = 140
Find the last names of faculties who are members of computer science department.
Additional table information: table: college_3
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'
What are the last names of faculty who are part of the computer science department?
Additional table information: table: college_3
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'
Find the average grade point of student whose last name is Smith.
Additional table information: table: college_3
SQL: SELECT AVG(T2.gradepoint) FROM ENROLLED_IN AS T1, GRADECONVERSION AS T2 JOIN STUDENT AS T3 ON T1.Grade = T2.lettergrade AND T1.StuID = T3.StuID WHERE T3.LName = 'Smith'
What is the average gradepoint for students with the last name Smith?
Additional table information: table: college_3
SQL: SELECT AVG(T2.gradepoint) FROM ENROLLED_IN AS T1, GRADECONVERSION AS T2 JOIN STUDENT AS T3 ON T1.Grade = T2.lettergrade AND T1.StuID = T3.StuID WHERE T3.LName = 'Smith'
What is the maximum and minimum grade point of students who live in NYC?
Additional table information: table: college_3
SQL: SELECT MAX(T2.gradepoint), MIN(T2.gradepoint) FROM ENROLLED_IN AS T1, GRADECONVERSION AS T2 JOIN STUDENT AS T3 ON T1.Grade = T2.lettergrade AND T1.StuID = T3.StuID WHERE T3.city_code = 'NYC'
Give the maximum and minimum gradepoints for students living in NYC?
Additional table information: table: college_3
SQL: SELECT MAX(T2.gradepoint), MIN(T2.gradepoint) FROM ENROLLED_IN AS T1, GRADECONVERSION AS T2 JOIN STUDENT AS T3 ON T1.Grade = T2.lettergrade AND T1.StuID = T3.StuID WHERE T3.city_code = 'NYC'
Find the names of courses that have either 3 credits or 1 credit but 4 hours.
Additional table information: table: college_3
SQL: SELECT CName FROM COURSE WHERE Credits = 3 UNION SELECT CName FROM COURSE WHERE Credits = 1 AND Hours = 4
What are the names of courses that give either 3 credits, or 1 credit and 4 hours?
Additional table information: table: college_3
SQL: SELECT CName FROM COURSE WHERE Credits = 3 UNION SELECT CName FROM COURSE WHERE Credits = 1 AND Hours = 4
Find the names of departments that are either in division AS or in division EN and in Building NEB.
Additional table information: table: college_3
SQL: SELECT DName FROM DEPARTMENT WHERE Division = 'AS' UNION SELECT DName FROM DEPARTMENT WHERE Division = 'EN' AND Building = 'NEB'
What are the names of departments either in division AS, or in division EN and in building NEB?
Additional table information: table: college_3
SQL: SELECT DName FROM DEPARTMENT WHERE Division = 'AS' UNION SELECT DName FROM DEPARTMENT WHERE Division = 'EN' AND Building = 'NEB'
Find the first name of students not enrolled in any course.
Additional table information: table: college_3
SQL: SELECT Fname FROM STUDENT WHERE NOT StuID IN (SELECT StuID FROM ENROLLED_IN)
What are the first names of all students that are not enrolled in courses?
Additional table information: table: college_3
SQL: SELECT Fname FROM STUDENT WHERE NOT StuID IN (SELECT StuID FROM ENROLLED_IN)
What are the ids of the top three products that were purchased in the largest amount?
Additional table information: table: department_store
SQL: SELECT product_id FROM product_suppliers ORDER BY total_amount_purchased DESC LIMIT 3
Give the ids of the three products purchased in the largest amounts.
Additional table information: table: department_store
SQL: SELECT product_id FROM product_suppliers ORDER BY total_amount_purchased DESC LIMIT 3
What are the product id and product type of the cheapest product?
Additional table information: table: department_store
SQL: SELECT product_id, product_type_code FROM products ORDER BY product_price NULLS FIRST LIMIT 1
Give the id and product type of the product with the lowest price.
Additional table information: table: department_store
SQL: SELECT product_id, product_type_code FROM products ORDER BY product_price NULLS FIRST LIMIT 1
Find the number of different product types.
Additional table information: table: department_store
SQL: SELECT COUNT(DISTINCT product_type_code) FROM products
Count the number of distinct product types.
Additional table information: table: department_store
SQL: SELECT COUNT(DISTINCT product_type_code) FROM products
Return the address of customer 10.
Additional table information: table: department_store
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
What is the address for the customer with id 10?
Additional table information: table: department_store
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
What are the staff ids and genders of all staffs whose job title is Department Manager?
Additional table information: table: department_store
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'
Return the staff ids and genders for any staff with the title Department Manager.
Additional table information: table: department_store
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'
For each payment method, return how many customers use it.
Additional table information: table: department_store
SQL: SELECT payment_method_code, COUNT(*) FROM customers GROUP BY payment_method_code
How many customers use each payment method?
Additional table information: table: department_store
SQL: SELECT payment_method_code, COUNT(*) FROM customers GROUP BY payment_method_code
What is the id of the product that was ordered the most often?
Additional table information: table: department_store
SQL: SELECT product_id FROM order_items GROUP BY product_id ORDER BY COUNT(*) DESC LIMIT 1
Give the product id for the product that was ordered most frequently.
Additional table information: table: department_store
SQL: SELECT product_id FROM order_items GROUP BY product_id ORDER BY COUNT(*) DESC LIMIT 1
What are the name, phone number and email address of the customer who made the largest number of orders?
Additional table information: table: department_store
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
Return the name, phone number and email address for the customer with the most orders.
Additional table information: table: department_store
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
What is the average price for each type of product?
Additional table information: table: department_store
SQL: SELECT product_type_code, AVG(product_price) FROM products GROUP BY product_type_code
Return the average price for each product type.
Additional table information: table: department_store
SQL: SELECT product_type_code, AVG(product_price) FROM products GROUP BY product_type_code
How many department stores does the store chain South have?
Additional table information: table: department_store
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'
Count the number of stores the chain South has.
Additional table information: table: department_store
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'
What is the name and job title of the staff who was assigned the latest?
Additional table information: table: department_store
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
Return the name and job title of the staff with the latest date assigned.
Additional table information: table: department_store
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
Give me the product type, name and price for all the products supplied by supplier id 3.
Additional table information: table: department_store
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
Return the product type, name, and price for products supplied by supplier 3.
Additional table information: table: department_store
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
Return the distinct name of customers whose order status is Pending, in the order of customer id.
Additional table information: table: department_store
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 NULLS FIRST
What are the distinct names of customers with an order status of Pending, sorted by customer id?
Additional table information: table: department_store
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 NULLS FIRST
Find the name and address of the customers who have both New and Pending orders.
Additional table information: table: department_store
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'
What are the names and addressed of customers who have both New and Pending orders?
Additional table information: table: department_store
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'
Return ids of all the products that are supplied by supplier id 2 and are more expensive than the average price of all products.
Additional table information: table: department_store
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)
What are the ids of products from the supplier with id 2, which are more expensive than the average price across all products?
Additional table information: table: department_store
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)
What is the id and name of the department store that has both marketing and managing department?
Additional table information: table: department_store
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'
What are the ids and names of department stores with both marketing and managing departments?
Additional table information: table: department_store
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'
What are the ids of the two department store chains with the largest number of department stores?
Additional table information: table: department_store
SQL: SELECT dept_store_chain_id FROM department_stores GROUP BY dept_store_chain_id ORDER BY COUNT(*) DESC LIMIT 2
Return the ids of the two department store chains with the most department stores.
Additional table information: table: department_store
SQL: SELECT dept_store_chain_id FROM department_stores GROUP BY dept_store_chain_id ORDER BY COUNT(*) DESC LIMIT 2
What is the id of the department with the least number of staff?
Additional table information: table: department_store
SQL: SELECT department_id FROM staff_department_assignments GROUP BY department_id ORDER BY COUNT(*) NULLS FIRST LIMIT 1
Return the id of the department with the fewest staff assignments.
Additional table information: table: department_store
SQL: SELECT department_id FROM staff_department_assignments GROUP BY department_id ORDER BY COUNT(*) NULLS FIRST LIMIT 1
For each product type, return the maximum and minimum price.
Additional table information: table: department_store
SQL: SELECT product_type_code, MAX(product_price), MIN(product_price) FROM products GROUP BY product_type_code
What are the maximum and minimum product prices for each product type?
Additional table information: table: department_store
SQL: SELECT product_type_code, MAX(product_price), MIN(product_price) FROM products GROUP BY product_type_code
Find the product type whose average price is higher than the average price of all products.
Additional table information: table: department_store
SQL: SELECT product_type_code FROM products GROUP BY product_type_code HAVING AVG(product_price) > (SELECT AVG(product_price) FROM products)
What is the code of the product type with an average price higher than the average price of all products?
Additional table information: table: department_store
SQL: SELECT product_type_code FROM products GROUP BY product_type_code HAVING AVG(product_price) > (SELECT AVG(product_price) FROM products)
Find the id and name of the staff who has been assigned for the shortest period.
Additional table information: table: department_store
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 NULLS FIRST LIMIT 1
What is the id and name of the staff who has been assigned for the least amount of time?
Additional table information: table: department_store
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 NULLS FIRST LIMIT 1
Return the names and ids of all products whose price is between 600 and 700.
Additional table information: table: department_store
SQL: SELECT product_name, product_id FROM products WHERE product_price BETWEEN 600 AND 700
What are the names and ids of products costing between 600 and 700?
Additional table information: table: department_store
SQL: SELECT product_name, product_id FROM products WHERE product_price BETWEEN 600 AND 700
Find the ids of all distinct customers who made order after some orders that were Cancelled.
Additional table information: table: department_store
SQL: SELECT DISTINCT customer_id FROM Customer_Orders WHERE order_date > (SELECT MIN(order_date) FROM Customer_Orders WHERE order_status_code = 'Cancelled')
What are the distinct ids of customers who made an order after any order that was Cancelled?
Additional table information: table: department_store
SQL: SELECT DISTINCT customer_id FROM Customer_Orders WHERE order_date > (SELECT MIN(order_date) FROM Customer_Orders WHERE order_status_code = 'Cancelled')
What is id of the staff who had a Staff Department Assignment earlier than any Clerical Staff?
Additional table information: table: department_store
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')
Return the id of the staff whose Staff Department Assignment was earlier than that of any Clerical Staff.
Additional table information: table: department_store
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')
What are the names and ids of customers whose address contains TN?
Additional table information: table: department_store
SQL: SELECT customer_name, customer_id FROM customers WHERE customer_address LIKE '%TN%'
Return the names and ids of customers who have TN in their address.
Additional table information: table: department_store
SQL: SELECT customer_name, customer_id FROM customers WHERE customer_address LIKE '%TN%'
Return the name and gender of the staff who was assigned in 2016.
Additional table information: table: department_store
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%'
What are the names and genders of staff who were assigned in 2016?
Additional table information: table: department_store
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%'
List the name of staff who has been assigned multiple jobs.
Additional table information: table: department_store
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
What are the names of staff who have been assigned multiple jobs?
Additional table information: table: department_store
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
List the name and phone number of all suppliers in the alphabetical order of their addresses.
Additional table information: table: department_store
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 NULLS FIRST
What are the names and phone numbers for all suppliers, sorted in alphabetical order of their addressed?
Additional table information: table: department_store
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 NULLS FIRST
What are the phone numbers of all customers and suppliers.
Additional table information: table: department_store
SQL: SELECT customer_phone FROM customers UNION SELECT supplier_phone FROM suppliers
Return the phone numbers for all customers and suppliers.
Additional table information: table: department_store
SQL: SELECT customer_phone FROM customers UNION SELECT supplier_phone FROM suppliers
Return the ids of all products that were ordered more than three times or supplied more than 80000.
Additional table information: table: department_store
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
What are the ids of all products that were either ordered more than 3 times or have a cumulative amount purchased of above 80000?
Additional table information: table: department_store
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
What are id and name of the products whose price is lower than 600 or higher than 900?
Additional table information: table: department_store
SQL: SELECT product_id, product_name FROM products WHERE product_price < 600 OR product_price > 900
Give the ids and names of products with price lower than 600 or higher than 900.
Additional table information: table: department_store
SQL: SELECT product_id, product_name FROM products WHERE product_price < 600 OR product_price > 900
Find the id of suppliers whose average amount purchased for each product is above 50000 or below 30000.
Additional table information: table: department_store
SQL: SELECT supplier_id FROM Product_Suppliers GROUP BY supplier_id HAVING AVG(total_amount_purchased) > 50000 OR AVG(total_amount_purchased) < 30000
What are the ids of suppliers which have an average amount purchased of above 50000 or below 30000?
Additional table information: table: department_store
SQL: SELECT supplier_id FROM Product_Suppliers GROUP BY supplier_id HAVING AVG(total_amount_purchased) > 50000 OR AVG(total_amount_purchased) < 30000
What are the average amount purchased and value purchased for the supplier who supplies the most products.
Additional table information: table: department_store
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)
Return the average total amount purchased and total value purchased for the supplier who supplies the greatest number of products.
Additional table information: table: department_store
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)
What is the largest and smallest customer codes?
Additional table information: table: department_store
SQL: SELECT MAX(customer_code), MIN(customer_code) FROM Customers
Return the maximum and minimum customer codes.
Additional table information: table: department_store
SQL: SELECT MAX(customer_code), MIN(customer_code) FROM Customers
List the names of all the distinct customers who bought a keyboard.
Additional table information: table: department_store
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'
What are the distinct names of customers who have purchased a keyboard?
Additional table information: table: department_store
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'
List the names and phone numbers of all the distinct suppliers who supply red jeans.
Additional table information: table: department_store
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'
What are the distinct names and phone numbers for suppliers who have red jeans?
Additional table information: table: department_store
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'
What are the highest and lowest prices of products, grouped by and alphabetically ordered by product type?
Additional table information: table: department_store
SQL: SELECT MAX(product_price), MIN(product_price), product_type_code FROM products GROUP BY product_type_code ORDER BY product_type_code NULLS FIRST
Give the maximum and minimum product prices for each product type, grouped and ordered by product type.
Additional table information: table: department_store
SQL: SELECT MAX(product_price), MIN(product_price), product_type_code FROM products GROUP BY product_type_code ORDER BY product_type_code NULLS FIRST
List the order id, customer id for orders in Cancelled status, ordered by their order dates.
Additional table information: table: department_store
SQL: SELECT order_id, customer_id FROM customer_orders WHERE order_status_code = 'Cancelled' ORDER BY order_date NULLS FIRST
What are the order ids and customer ids for orders that have been Cancelled, sorted by their order dates?
Additional table information: table: department_store
SQL: SELECT order_id, customer_id FROM customer_orders WHERE order_status_code = 'Cancelled' ORDER BY order_date NULLS FIRST
Find the names of products that were bought by at least two distinct customers.
Additional table information: table: department_store
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
What are the distinct names of products purchased by at least two different customers?
Additional table information: table: department_store
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
Find the names of customers who have bought by at least three distinct products.
Additional table information: table: department_store
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
What are the distinct names of customers who have purchased at least three different products?
Additional table information: table: department_store
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
Find the name and gender of the staff who has been assigned the job of Sales Person but never Clerical Staff.
Additional table information: table: department_store
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'
What are the names and genders of staff who have held the title Sales Person, but never Clerical Staff?
Additional table information: table: department_store
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'
Find the id and name of customers whose address contains WY state and do not use credit card for payment.
Additional table information: table: department_store
SQL: SELECT customer_id, customer_name FROM customers WHERE customer_address LIKE '%WY%' AND payment_method_code <> 'Credit Card'
What are the ids and names of customers with addressed that contain WY and who do not use a credit card for payment?
Additional table information: table: department_store
SQL: SELECT customer_id, customer_name FROM customers WHERE customer_address LIKE '%WY%' AND payment_method_code <> 'Credit Card'
Find the average price of all product clothes.
Additional table information: table: department_store
SQL: SELECT AVG(product_price) FROM products WHERE product_type_code = 'Clothes'
What is the average price of clothes?
Additional table information: table: department_store
SQL: SELECT AVG(product_price) FROM products WHERE product_type_code = 'Clothes'
Find the name of the most expensive hardware product.
Additional table information: table: department_store
SQL: SELECT product_name FROM products WHERE product_type_code = 'Hardware' ORDER BY product_price DESC LIMIT 1
What is the name of the hardware product with the greatest price?
Additional table information: table: department_store
SQL: SELECT product_name FROM products WHERE product_type_code = 'Hardware' ORDER BY product_price DESC LIMIT 1