human
Schema:
Addresses (address_id, line_1_number_building, city, zip_postcode, state_province_county, country)
Products (product_id, product_type_code, product_name, product_price)
Customers (customer_id, payment_method_code, customer_number, customer_name, customer_address, customer_phone, customer_email)
Contacts (contact_id, customer_id, gender, first_name, last_name, contact_phone)
Customer_Address_History (customer_id, address_id, date_from, date_to)
Customer_Orders (order_id, customer_id, order_date, order_status_code)
Order_Items (order_item_id, order_id, product_id, order_quantity)
Please answer with SQL.
assistant
Sure, I understand.
human
Show the names of all customers.
assistant
SELECT customer_name FROM customers;
human
Also show their phone numbers.
assistant
SELECT customer_name , customer_phone FROM customers;
human
For each of them, what is the total product quantity of their orders?
assistant
SELECT T1.customer_name , T1.customer_phone , SUM( T3.order_quantity ) FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id JOIN order_items AS T3 ON T3.order_id = T2.order_id GROUP BY T1.customer_id ;