human
Schema:
Staff (staff_id, gender, first_name, last_name, email_address, phone_number)
Customers (customer_id, customer_type_code, address_line_1, address_line_2, town_city, state, email_address, phone_number)
Products (product_id, parent_product_id, product_category_code, date_product_first_available, date_product_discontinued, product_name, product_description, product_price)
Complaints (complaint_id, product_id, customer_id, complaint_outcome_code, complaint_status_code, complaint_type_code, date_complaint_raised, date_complaint_closed, staff_id)
Please answer with SQL.
assistant
Sure, I understand.
human
What date was the most recent complaint raised?
assistant
SELECT date_complaint_raised FROM complaints ORDER by date_complaint_raised desc LIMIT 1;
human
Was this complaint closed? | Do you mean whether the complaint which raised at 2007-10-14 21:50:43 was closed? | Correct. Has the complaint raised at 2007-10-14 21:50:43 been closed?
assistant
SELECT date_complaint_closed FROM complaints WHERE date_complaint_raised = '2007-10-14 21:50:43';
human
What is the customer id for that complaint? | Do you mean the customer id for the complaint which raised at 2007-10-14 21:50:43? | Correct. What is the customer id for the complaint raised at 2007-10-14 21:50:43?
assistant
SELECT customer_id FROM complaints WHERE date_complaint_raised = '2007-10-14 21:50:43';
human
What is the phone number for customer id 118?
assistant
SELECT phone_number FROM customers WHERE customer_id = 118 ;