db_name
stringclasses
146 values
prompt
stringlengths
310
4.81k
college_3
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code ) # Faculty ( FacID, Lname, Fname, Rank, Sex, Phone, Room, Building ) # Department ( DNO, Division, DName, Room, Building, DPhone ) # Member_of ( FacID, DNO, Appt_Type ) # Course ( CID, CName, Credits, Instructor, Days, Hours, DNO ) # Minor_in ( StuID, DNO ) # Enrolled_in ( StuID, CID, Grade ) # Gradeconversion ( lettergrade, gradepoint ) # # Member_of.DNO can be joined with Department.DNO # Member_of.FacID can be joined with Faculty.FacID # Course.DNO can be joined with Department.DNO # Course.Instructor can be joined with Faculty.FacID # Minor_in.DNO can be joined with Department.DNO # Minor_in.StuID can be joined with Student.StuID # Enrolled_in.Grade can be joined with Gradeconversion.lettergrade # Enrolled_in.CID can be joined with Course.CID # Enrolled_in.StuID can be joined with Student.StuID # ### Question: # # What is the average gradepoint for students with the last name Smith? # ### 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" # ### End.
college_3
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code ) # Faculty ( FacID, Lname, Fname, Rank, Sex, Phone, Room, Building ) # Department ( DNO, Division, DName, Room, Building, DPhone ) # Member_of ( FacID, DNO, Appt_Type ) # Course ( CID, CName, Credits, Instructor, Days, Hours, DNO ) # Minor_in ( StuID, DNO ) # Enrolled_in ( StuID, CID, Grade ) # Gradeconversion ( lettergrade, gradepoint ) # # Member_of.DNO can be joined with Department.DNO # Member_of.FacID can be joined with Faculty.FacID # Course.DNO can be joined with Department.DNO # Course.Instructor can be joined with Faculty.FacID # Minor_in.DNO can be joined with Department.DNO # Minor_in.StuID can be joined with Student.StuID # Enrolled_in.Grade can be joined with Gradeconversion.lettergrade # Enrolled_in.CID can be joined with Course.CID # Enrolled_in.StuID can be joined with Student.StuID # ### Question: # # What is the maximum and minimum grade point of students who live in NYC? # ### 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" # ### End.
college_3
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code ) # Faculty ( FacID, Lname, Fname, Rank, Sex, Phone, Room, Building ) # Department ( DNO, Division, DName, Room, Building, DPhone ) # Member_of ( FacID, DNO, Appt_Type ) # Course ( CID, CName, Credits, Instructor, Days, Hours, DNO ) # Minor_in ( StuID, DNO ) # Enrolled_in ( StuID, CID, Grade ) # Gradeconversion ( lettergrade, gradepoint ) # # Member_of.DNO can be joined with Department.DNO # Member_of.FacID can be joined with Faculty.FacID # Course.DNO can be joined with Department.DNO # Course.Instructor can be joined with Faculty.FacID # Minor_in.DNO can be joined with Department.DNO # Minor_in.StuID can be joined with Student.StuID # Enrolled_in.Grade can be joined with Gradeconversion.lettergrade # Enrolled_in.CID can be joined with Course.CID # Enrolled_in.StuID can be joined with Student.StuID # ### Question: # # Give the maximum and minimum gradepoints for students living in NYC? # ### 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" # ### End.
college_3
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code ) # Faculty ( FacID, Lname, Fname, Rank, Sex, Phone, Room, Building ) # Department ( DNO, Division, DName, Room, Building, DPhone ) # Member_of ( FacID, DNO, Appt_Type ) # Course ( CID, CName, Credits, Instructor, Days, Hours, DNO ) # Minor_in ( StuID, DNO ) # Enrolled_in ( StuID, CID, Grade ) # Gradeconversion ( lettergrade, gradepoint ) # # Member_of.DNO can be joined with Department.DNO # Member_of.FacID can be joined with Faculty.FacID # Course.DNO can be joined with Department.DNO # Course.Instructor can be joined with Faculty.FacID # Minor_in.DNO can be joined with Department.DNO # Minor_in.StuID can be joined with Student.StuID # Enrolled_in.Grade can be joined with Gradeconversion.lettergrade # Enrolled_in.CID can be joined with Course.CID # Enrolled_in.StuID can be joined with Student.StuID # ### Question: # # Find the names of courses that have either 3 credits or 1 credit but 4 hours. # ### SQL: # # SELECT CName FROM COURSE WHERE Credits = 3 UNION SELECT CName FROM COURSE WHERE Credits = 1 AND Hours = 4 # ### End.
college_3
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code ) # Faculty ( FacID, Lname, Fname, Rank, Sex, Phone, Room, Building ) # Department ( DNO, Division, DName, Room, Building, DPhone ) # Member_of ( FacID, DNO, Appt_Type ) # Course ( CID, CName, Credits, Instructor, Days, Hours, DNO ) # Minor_in ( StuID, DNO ) # Enrolled_in ( StuID, CID, Grade ) # Gradeconversion ( lettergrade, gradepoint ) # # Member_of.DNO can be joined with Department.DNO # Member_of.FacID can be joined with Faculty.FacID # Course.DNO can be joined with Department.DNO # Course.Instructor can be joined with Faculty.FacID # Minor_in.DNO can be joined with Department.DNO # Minor_in.StuID can be joined with Student.StuID # Enrolled_in.Grade can be joined with Gradeconversion.lettergrade # Enrolled_in.CID can be joined with Course.CID # Enrolled_in.StuID can be joined with Student.StuID # ### Question: # # What are the names of courses that give either 3 credits, or 1 credit and 4 hours? # ### SQL: # # SELECT CName FROM COURSE WHERE Credits = 3 UNION SELECT CName FROM COURSE WHERE Credits = 1 AND Hours = 4 # ### End.
college_3
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code ) # Faculty ( FacID, Lname, Fname, Rank, Sex, Phone, Room, Building ) # Department ( DNO, Division, DName, Room, Building, DPhone ) # Member_of ( FacID, DNO, Appt_Type ) # Course ( CID, CName, Credits, Instructor, Days, Hours, DNO ) # Minor_in ( StuID, DNO ) # Enrolled_in ( StuID, CID, Grade ) # Gradeconversion ( lettergrade, gradepoint ) # # Member_of.DNO can be joined with Department.DNO # Member_of.FacID can be joined with Faculty.FacID # Course.DNO can be joined with Department.DNO # Course.Instructor can be joined with Faculty.FacID # Minor_in.DNO can be joined with Department.DNO # Minor_in.StuID can be joined with Student.StuID # Enrolled_in.Grade can be joined with Gradeconversion.lettergrade # Enrolled_in.CID can be joined with Course.CID # Enrolled_in.StuID can be joined with Student.StuID # ### Question: # # Find the names of departments that are either in division AS or in division EN and in Building NEB. # ### SQL: # # SELECT DName FROM DEPARTMENT WHERE Division = "AS" UNION SELECT DName FROM DEPARTMENT WHERE Division = "EN" AND Building = "NEB" # ### End.
college_3
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code ) # Faculty ( FacID, Lname, Fname, Rank, Sex, Phone, Room, Building ) # Department ( DNO, Division, DName, Room, Building, DPhone ) # Member_of ( FacID, DNO, Appt_Type ) # Course ( CID, CName, Credits, Instructor, Days, Hours, DNO ) # Minor_in ( StuID, DNO ) # Enrolled_in ( StuID, CID, Grade ) # Gradeconversion ( lettergrade, gradepoint ) # # Member_of.DNO can be joined with Department.DNO # Member_of.FacID can be joined with Faculty.FacID # Course.DNO can be joined with Department.DNO # Course.Instructor can be joined with Faculty.FacID # Minor_in.DNO can be joined with Department.DNO # Minor_in.StuID can be joined with Student.StuID # Enrolled_in.Grade can be joined with Gradeconversion.lettergrade # Enrolled_in.CID can be joined with Course.CID # Enrolled_in.StuID can be joined with Student.StuID # ### Question: # # What are the names of departments either in division AS, or in division EN and in building NEB? # ### SQL: # # SELECT DName FROM DEPARTMENT WHERE Division = "AS" UNION SELECT DName FROM DEPARTMENT WHERE Division = "EN" AND Building = "NEB" # ### End.
college_3
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code ) # Faculty ( FacID, Lname, Fname, Rank, Sex, Phone, Room, Building ) # Department ( DNO, Division, DName, Room, Building, DPhone ) # Member_of ( FacID, DNO, Appt_Type ) # Course ( CID, CName, Credits, Instructor, Days, Hours, DNO ) # Minor_in ( StuID, DNO ) # Enrolled_in ( StuID, CID, Grade ) # Gradeconversion ( lettergrade, gradepoint ) # # Member_of.DNO can be joined with Department.DNO # Member_of.FacID can be joined with Faculty.FacID # Course.DNO can be joined with Department.DNO # Course.Instructor can be joined with Faculty.FacID # Minor_in.DNO can be joined with Department.DNO # Minor_in.StuID can be joined with Student.StuID # Enrolled_in.Grade can be joined with Gradeconversion.lettergrade # Enrolled_in.CID can be joined with Course.CID # Enrolled_in.StuID can be joined with Student.StuID # ### Question: # # Find the first name of students not enrolled in any course. # ### SQL: # # SELECT Fname FROM STUDENT WHERE StuID NOT IN (SELECT StuID FROM ENROLLED_IN) # ### End.
college_3
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code ) # Faculty ( FacID, Lname, Fname, Rank, Sex, Phone, Room, Building ) # Department ( DNO, Division, DName, Room, Building, DPhone ) # Member_of ( FacID, DNO, Appt_Type ) # Course ( CID, CName, Credits, Instructor, Days, Hours, DNO ) # Minor_in ( StuID, DNO ) # Enrolled_in ( StuID, CID, Grade ) # Gradeconversion ( lettergrade, gradepoint ) # # Member_of.DNO can be joined with Department.DNO # Member_of.FacID can be joined with Faculty.FacID # Course.DNO can be joined with Department.DNO # Course.Instructor can be joined with Faculty.FacID # Minor_in.DNO can be joined with Department.DNO # Minor_in.StuID can be joined with Student.StuID # Enrolled_in.Grade can be joined with Gradeconversion.lettergrade # Enrolled_in.CID can be joined with Course.CID # Enrolled_in.StuID can be joined with Student.StuID # ### Question: # # What are the first names of all students that are not enrolled in courses? # ### SQL: # # SELECT Fname FROM STUDENT WHERE StuID NOT IN (SELECT StuID FROM ENROLLED_IN) # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # What are the ids of the top three products that were purchased in the largest amount? # ### SQL: # # SELECT product_id FROM product_suppliers ORDER BY total_amount_purchased DESC LIMIT 3 # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # Give the ids of the three products purchased in the largest amounts. # ### SQL: # # SELECT product_id FROM product_suppliers ORDER BY total_amount_purchased DESC LIMIT 3 # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # What are the product id and product type of the cheapest product? # ### SQL: # # SELECT product_id , product_type_code FROM products ORDER BY product_price LIMIT 1 # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # Give the id and product type of the product with the lowest price. # ### SQL: # # SELECT product_id , product_type_code FROM products ORDER BY product_price LIMIT 1 # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # Find the number of different product types. # ### SQL: # # SELECT count(DISTINCT product_type_code) FROM products # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # Count the number of distinct product types. # ### SQL: # # SELECT count(DISTINCT product_type_code) FROM products # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # Return the address of customer 10. # ### 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 # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # What is the address for the customer with id 10? # ### 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 # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # What are the staff ids and genders of all staffs whose job title is Department Manager? # ### 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" # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # Return the staff ids and genders for any staff with the title Department Manager. # ### 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" # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # For each payment method, return how many customers use it. # ### SQL: # # SELECT payment_method_code , count(*) FROM customers GROUP BY payment_method_code # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # How many customers use each payment method? # ### SQL: # # SELECT payment_method_code , count(*) FROM customers GROUP BY payment_method_code # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # What is the id of the product that was ordered the most often? # ### SQL: # # SELECT product_id FROM order_items GROUP BY product_id ORDER BY count(*) DESC LIMIT 1 # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # Give the product id for the product that was ordered most frequently. # ### SQL: # # SELECT product_id FROM order_items GROUP BY product_id ORDER BY count(*) DESC LIMIT 1 # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # What are the name, phone number and email address of the customer who made the largest number of orders? # ### 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 # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # Return the name, phone number and email address for the customer with the most orders. # ### 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 # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # What is the average price for each type of product? # ### SQL: # # SELECT product_type_code , avg(product_price) FROM products GROUP BY product_type_code # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # Return the average price for each product type. # ### SQL: # # SELECT product_type_code , avg(product_price) FROM products GROUP BY product_type_code # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # How many department stores does the store chain South have? # ### 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" # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # Count the number of stores the chain South has. # ### 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" # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # What is the name and job title of the staff who was assigned the latest? # ### 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 # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # Return the name and job title of the staff with the latest date assigned. # ### 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 # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # Give me the product type, name and price for all the products supplied by supplier id 3. # ### 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 # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # Return the product type, name, and price for products supplied by supplier 3. # ### 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 # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # Return the distinct name of customers whose order status is Pending, in the order of customer id. # ### 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 # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # What are the distinct names of customers with an order status of Pending, sorted by customer id? # ### 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 # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # Find the name and address of the customers who have both New and Pending orders. # ### 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" # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # What are the names and addressed of customers who have both New and Pending orders? # ### 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" # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### 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. # ### 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) # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # What are the ids of products from the supplier with id 2, which are more expensive than the average price across all products? # ### 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) # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # What is the id and name of the department store that has both marketing and managing department? # ### 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" # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # What are the ids and names of department stores with both marketing and managing departments? # ### 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" # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # What are the ids of the two department store chains with the largest number of department stores? # ### SQL: # # SELECT dept_store_chain_id FROM department_stores GROUP BY dept_store_chain_id ORDER BY count(*) DESC LIMIT 2 # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # Return the ids of the two department store chains with the most department stores. # ### SQL: # # SELECT dept_store_chain_id FROM department_stores GROUP BY dept_store_chain_id ORDER BY count(*) DESC LIMIT 2 # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # What is the id of the department with the least number of staff? # ### SQL: # # SELECT department_id FROM staff_department_assignments GROUP BY department_id ORDER BY count(*) LIMIT 1 # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # Return the id of the department with the fewest staff assignments. # ### SQL: # # SELECT department_id FROM staff_department_assignments GROUP BY department_id ORDER BY count(*) LIMIT 1 # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # For each product type, return the maximum and minimum price. # ### SQL: # # SELECT product_type_code , max(product_price) , min(product_price) FROM products GROUP BY product_type_code # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # What are the maximum and minimum product prices for each product type? # ### SQL: # # SELECT product_type_code , max(product_price) , min(product_price) FROM products GROUP BY product_type_code # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # Find the product type whose average price is higher than the average price of all products. # ### SQL: # # SELECT product_type_code FROM products GROUP BY product_type_code HAVING avg(product_price) > (SELECT avg(product_price) FROM products) # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # What is the code of the product type with an average price higher than the average price of all products? # ### SQL: # # SELECT product_type_code FROM products GROUP BY product_type_code HAVING avg(product_price) > (SELECT avg(product_price) FROM products) # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # Find the id and name of the staff who has been assigned for the shortest period. # ### 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 # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # What is the id and name of the staff who has been assigned for the least amount of time? # ### 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 # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # Return the names and ids of all products whose price is between 600 and 700. # ### SQL: # # SELECT product_name , product_id FROM products WHERE product_price BETWEEN 600 AND 700 # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # What are the names and ids of products costing between 600 and 700? # ### SQL: # # SELECT product_name , product_id FROM products WHERE product_price BETWEEN 600 AND 700 # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # Find the ids of all distinct customers who made order after some orders that were Cancelled. # ### SQL: # # SELECT DISTINCT customer_id FROM Customer_Orders WHERE order_date > (SELECT min(order_date) FROM Customer_Orders WHERE order_status_code = "Cancelled") # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # What are the distinct ids of customers who made an order after any order that was Cancelled? # ### SQL: # # SELECT DISTINCT customer_id FROM Customer_Orders WHERE order_date > (SELECT min(order_date) FROM Customer_Orders WHERE order_status_code = "Cancelled") # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # What is id of the staff who had a Staff Department Assignment earlier than any Clerical Staff? # ### 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') # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # Return the id of the staff whose Staff Department Assignment was earlier than that of any Clerical Staff. # ### 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') # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # What are the names and ids of customers whose address contains TN? # ### SQL: # # SELECT customer_name , customer_id FROM customers WHERE customer_address LIKE "%TN%" # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # Return the names and ids of customers who have TN in their address. # ### SQL: # # SELECT customer_name , customer_id FROM customers WHERE customer_address LIKE "%TN%" # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # Return the name and gender of the staff who was assigned in 2016. # ### 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%" # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # What are the names and genders of staff who were assigned in 2016? # ### 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%" # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # List the name of staff who has been assigned multiple jobs. # ### 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 # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # What are the names of staff who have been assigned multiple jobs? # ### 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 # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # List the name and phone number of all suppliers in the alphabetical order of their addresses. # ### 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 # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # What are the names and phone numbers for all suppliers, sorted in alphabetical order of their addressed? # ### 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 # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # What are the phone numbers of all customers and suppliers. # ### SQL: # # SELECT customer_phone FROM customers UNION SELECT supplier_phone FROM suppliers # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # Return the phone numbers for all customers and suppliers. # ### SQL: # # SELECT customer_phone FROM customers UNION SELECT supplier_phone FROM suppliers # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # Return the ids of all products that were ordered more than three times or supplied more than 80000. # ### 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 # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # What are the ids of all products that were either ordered more than 3 times or have a cumulative amount purchased of above 80000? # ### 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 # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # What are id and name of the products whose price is lower than 600 or higher than 900? # ### SQL: # # SELECT product_id , product_name FROM products WHERE product_price < 600 OR product_price > 900 # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # Give the ids and names of products with price lower than 600 or higher than 900. # ### SQL: # # SELECT product_id , product_name FROM products WHERE product_price < 600 OR product_price > 900 # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # Find the id of suppliers whose average amount purchased for each product is above 50000 or below 30000. # ### SQL: # # SELECT supplier_id FROM Product_Suppliers GROUP BY supplier_id HAVING avg(total_amount_purchased) > 50000 OR avg(total_amount_purchased) < 30000 # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # What are the ids of suppliers which have an average amount purchased of above 50000 or below 30000? # ### SQL: # # SELECT supplier_id FROM Product_Suppliers GROUP BY supplier_id HAVING avg(total_amount_purchased) > 50000 OR avg(total_amount_purchased) < 30000 # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # What are the average amount purchased and value purchased for the supplier who supplies the most products. # ### 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) # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # Return the average total amount purchased and total value purchased for the supplier who supplies the greatest number of products. # ### 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) # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # What is the largest and smallest customer codes? # ### SQL: # # SELECT max(customer_code) , min(customer_code) FROM Customers # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # Return the maximum and minimum customer codes. # ### SQL: # # SELECT max(customer_code) , min(customer_code) FROM Customers # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # List the names of all the distinct customers who bought a keyboard. # ### 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" # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # What are the distinct names of customers who have purchased a keyboard? # ### 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" # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # List the names and phone numbers of all the distinct suppliers who supply red jeans. # ### 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" # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # What are the distinct names and phone numbers for suppliers who have red jeans? # ### 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" # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # What are the highest and lowest prices of products, grouped by and alphabetically ordered by product type? # ### SQL: # # SELECT max(product_price) , min(product_price) , product_type_code FROM products GROUP BY product_type_code ORDER BY product_type_code # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # Give the maximum and minimum product prices for each product type, grouped and ordered by product type. # ### SQL: # # SELECT max(product_price) , min(product_price) , product_type_code FROM products GROUP BY product_type_code ORDER BY product_type_code # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # List the order id, customer id for orders in Cancelled status, ordered by their order dates. # ### SQL: # # SELECT order_id , customer_id FROM customer_orders WHERE order_status_code = "Cancelled" ORDER BY order_date # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # What are the order ids and customer ids for orders that have been Cancelled, sorted by their order dates? # ### SQL: # # SELECT order_id , customer_id FROM customer_orders WHERE order_status_code = "Cancelled" ORDER BY order_date # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # Find the names of products that were bought by at least two distinct customers. # ### 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 # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # What are the distinct names of products purchased by at least two different customers? # ### 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 # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # Find the names of customers who have bought by at least three distinct products. # ### 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 # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # What are the distinct names of customers who have purchased at least three different products? # ### 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 # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # Find the name and gender of the staff who has been assigned the job of Sales Person but never Clerical Staff. # ### 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" # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # What are the names and genders of staff who have held the title Sales Person, but never Clerical Staff? # ### 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" # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # Find the id and name of customers whose address contains WY state and do not use credit card for payment. # ### SQL: # # SELECT customer_id , customer_name FROM customers WHERE customer_address LIKE "%WY%" AND payment_method_code != "Credit Card" # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # What are the ids and names of customers with addressed that contain WY and who do not use a credit card for payment? # ### SQL: # # SELECT customer_id , customer_name FROM customers WHERE customer_address LIKE "%WY%" AND payment_method_code != "Credit Card" # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # Find the average price of all product clothes. # ### SQL: # # SELECT avg(product_price) FROM products WHERE product_type_code = 'Clothes' # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # What is the average price of clothes? # ### SQL: # # SELECT avg(product_price) FROM products WHERE product_type_code = 'Clothes' # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # Find the name of the most expensive hardware product. # ### SQL: # # SELECT product_name FROM products WHERE product_type_code = 'Hardware' ORDER BY product_price DESC LIMIT 1 # ### End.
department_store
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, address_details ) # Staff ( staff_id, staff_gender, staff_name ) # Suppliers ( supplier_id, supplier_name, supplier_phone ) # Department_Store_Chain ( dept_store_chain_id, dept_store_chain_name ) # Customers ( customer_id, payment_method_code, customer_code, customer_name, customer_address, customer_phone, customer_email ) # Products ( product_id, product_type_code, product_name, product_price ) # Supplier_Addresses ( supplier_id, address_id, date_from, date_to ) # Customer_Addresses ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_status_code, order_date ) # Department_Stores ( dept_store_id, dept_store_chain_id, store_name, store_address, store_phone, store_email ) # Departments ( department_id, dept_store_id, department_name ) # Order_Items ( order_item_id, order_id, product_id ) # Product_Suppliers ( product_id, supplier_id, date_supplied_from, date_supplied_to, total_amount_purchased, total_value_purchased ) # Staff_Department_Assignments ( staff_id, department_id, date_assigned_from, job_title_code, date_assigned_to ) # # Supplier_Addresses.supplier_id can be joined with Suppliers.supplier_id # Supplier_Addresses.address_id can be joined with Addresses.address_id # Customer_Addresses.customer_id can be joined with Customers.customer_id # Customer_Addresses.address_id can be joined with Addresses.address_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Department_Stores.dept_store_chain_id can be joined with Department_Store_Chain.dept_store_chain_id # Departments.dept_store_id can be joined with Department_Stores.dept_store_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Product_Suppliers.product_id can be joined with Products.product_id # Product_Suppliers.supplier_id can be joined with Suppliers.supplier_id # Staff_Department_Assignments.staff_id can be joined with Staff.staff_id # Staff_Department_Assignments.department_id can be joined with Departments.department_id # ### Question: # # What is the name of the hardware product with the greatest price? # ### SQL: # # SELECT product_name FROM products WHERE product_type_code = 'Hardware' ORDER BY product_price DESC LIMIT 1 # ### End.
aircraft
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # pilot ( Pilot_Id, Name, Age ) # aircraft ( Aircraft_ID, Aircraft, Description, Max_Gross_Weight, Total_disk_area, Max_disk_Loading ) # match ( Round, Location, Country, Date, Fastest_Qualifying, Winning_Pilot, Winning_Aircraft ) # airport ( Airport_ID, Airport_Name, Total_Passengers, %_Change_2007, International_Passengers, Domestic_Passengers, Transit_Passengers, Aircraft_Movements, Freight_Metric_Tonnes ) # airport_aircraft ( ID, Airport_ID, Aircraft_ID ) # # match.Winning_Pilot can be joined with pilot.Pilot_Id # match.Winning_Aircraft can be joined with aircraft.Aircraft_ID # airport_aircraft.Aircraft_ID can be joined with aircraft.Aircraft_ID # airport_aircraft.Airport_ID can be joined with airport.Airport_ID # ### Question: # # How many aircrafts are there? # ### SQL: # # SELECT count(*) FROM aircraft # ### End.
aircraft
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # pilot ( Pilot_Id, Name, Age ) # aircraft ( Aircraft_ID, Aircraft, Description, Max_Gross_Weight, Total_disk_area, Max_disk_Loading ) # match ( Round, Location, Country, Date, Fastest_Qualifying, Winning_Pilot, Winning_Aircraft ) # airport ( Airport_ID, Airport_Name, Total_Passengers, %_Change_2007, International_Passengers, Domestic_Passengers, Transit_Passengers, Aircraft_Movements, Freight_Metric_Tonnes ) # airport_aircraft ( ID, Airport_ID, Aircraft_ID ) # # match.Winning_Pilot can be joined with pilot.Pilot_Id # match.Winning_Aircraft can be joined with aircraft.Aircraft_ID # airport_aircraft.Aircraft_ID can be joined with aircraft.Aircraft_ID # airport_aircraft.Airport_ID can be joined with airport.Airport_ID # ### Question: # # What is the number of aircraft? # ### SQL: # # SELECT count(*) FROM aircraft # ### End.
aircraft
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # pilot ( Pilot_Id, Name, Age ) # aircraft ( Aircraft_ID, Aircraft, Description, Max_Gross_Weight, Total_disk_area, Max_disk_Loading ) # match ( Round, Location, Country, Date, Fastest_Qualifying, Winning_Pilot, Winning_Aircraft ) # airport ( Airport_ID, Airport_Name, Total_Passengers, %_Change_2007, International_Passengers, Domestic_Passengers, Transit_Passengers, Aircraft_Movements, Freight_Metric_Tonnes ) # airport_aircraft ( ID, Airport_ID, Aircraft_ID ) # # match.Winning_Pilot can be joined with pilot.Pilot_Id # match.Winning_Aircraft can be joined with aircraft.Aircraft_ID # airport_aircraft.Aircraft_ID can be joined with aircraft.Aircraft_ID # airport_aircraft.Airport_ID can be joined with airport.Airport_ID # ### Question: # # List the description of all aircrafts. # ### SQL: # # SELECT Description FROM aircraft # ### End.