Database: department_store

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

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

Question: Find the number of different product types.
SQL: SELECT count(DISTINCT product_type_code) FROM products

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

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"

Question: For each payment method, return how many customers use it.
SQL: SELECT payment_method_code ,  count(*) FROM customers GROUP BY payment_method_code

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

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

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

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"

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

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

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