human
Schema:
Customers (customer_id, customer_name, customer_details)
Invoices (invoice_number, invoice_date, invoice_details)
Orders (order_id, customer_id, order_status, date_order_placed, order_details)
Products (product_id, product_name, product_details)
Order_Items (order_item_id, product_id, order_id, order_item_status, order_item_details)
Shipments (shipment_id, order_id, invoice_number, shipment_tracking_number, shipment_date, other_shipment_details)
Shipment_Items (shipment_id, order_item_id)
Please answer with SQL.
assistant
Sure, I understand.
human
What is the placement date of the order whose invoice number is 10?
assistant
SELECT T1.date_order_placed FROM orders AS T1 JOIN shipments AS T2 ON T1.order_id = T2.order_id WHERE T2.invoice_number = 10
human
Find the names of the customers who have order status both 'On Road' and 'Shipped'.
assistant
SELECT T1.customer_name FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status = 'On Road' INTERSECT SELECT T1.customer_name FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status = 'Shipped'
human
Find the ids of orders which are shipped after 2000-01-01.
assistant
SELECT order_id FROM shipments WHERE shipment_date > '2000-01-01'
human
Find the id of the order which is shipped most recently.
assistant
SELECT order_id FROM shipments WHERE shipment_date = (SELECT max(shipment_date) FROM shipments)
human
Find the id of the order whose shipment tracking number is '3452'.
assistant
SELECT order_id FROM shipments WHERE shipment_tracking_number = '3452'
human
On which day was the order placed whose shipment tracking number is 3452?
assistant
SELECT T1.date_order_placed FROM orders AS T1 JOIN shipments AS T2 ON T1.order_id = T2.order_id WHERE T2.shipment_tracking_number = 3452 ;