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
How many customers are there?
assistant
SELECT count(*) FROM customers
human
Find the name of customers who are living in Colorado?
assistant
SELECT t1.customer_name FROM customers AS t1 JOIN customer_addresses AS t2 ON t1.customer_id = t2.customer_id JOIN addresses AS t3 ON t2.address_id = t3.address_id WHERE t3.state_province_county = 'Colorado'
human
Find the names of customers who never placed an order.
assistant
SELECT customer_name FROM customers EXCEPT SELECT t1.customer_name FROM customers AS t1 JOIN customer_orders AS t2 ON t1.customer_id = t2.customer_id
human
Find the name of customers who did not pay with Cash.
assistant
SELECT customer_name FROM customers WHERE payment_method != 'Cash'
human
Find the name of all customers whose name contains 'Alex'.
assistant
SELECT customer_name FROM customers WHERE customer_name LIKE '%Alex%'
human
Find the name of all customers.
assistant
SELECT customer_name FROM customers ;