human
Schema:
Addresses (address_id, address_content, city, zip_postcode, state_province_county, country, other_address_details)
Products (product_id, product_details)
Customers (customer_id, payment_method, customer_name, date_became_customer, other_customer_details)
Customer_Addresses (customer_id, address_id, date_address_from, address_type, date_address_to)
Customer_Contact_Channels (customer_id, channel_code, active_from_date, active_to_date, contact_number)
Customer_Orders (order_id, customer_id, order_status, order_date, order_details)
Order_Items (order_id, product_id, order_quantity)
Please answer with SQL.
assistant
Sure, I understand.
human
Please tell me the product names and ids. | Did you mean all the product details and ids? | Yes please.
assistant
SELECT product_details , product_id FROM Products;
human
Hmm, I want to know the product names and the order quantities. | Did you mean the product details as product names? | Yes.
assistant
SELECT T1.product_details , T2.order_quantity FROM Products AS T1 JOIN Order_Items AS T2 ON T1.product_id = T2.product_id;
human
Can you tell which product has been ordered the most number of times?
assistant
SELECT t2.product_details FROM order_items AS t1 JOIN products AS t2 ON t1.product_id = t2.product_id GROUP BY t1.product_id ORDER BY COUNT( * ) DESC LIMIT 1 ;