[Schema (values) (types)]: | customer_deliveries |  Products : product_id (text) , product_name (number) , product_price (text) , product_description (number) | Addresses : address_id (text) , address_details (number) , city (text) , zip_postcode (number) , state_province_county (text) , country (number) | Customers : customer_id (text) , payment_method (number) , customer_name (text) , customer_phone (number) , customer_email (text) , date_became_customer (number) | Regular_Orders : regular_order_id (text) , distributer_id (number) | Regular_Order_Products : regular_order_id (text) , product_id (number) | Actual_Orders : actual_order_id (text) , order_status_code (number) , regular_order_id (text) , actual_order_date (number) | Actual_Order_Products : actual_order_id (text) , product_id (number) | Customer_Addresses : customer_id (text) , address_id (number) , date_from (text) , address_type (number) , date_to (text) | Delivery_Routes : route_id (text) , route_name (number) , other_route_details (text) | Delivery_Route_Locations : location_code (text) , route_id (number) , location_address_id (text) , location_name (number) | Trucks : truck_id (text) , truck_licence_number (number) , truck_details (text) | Employees : employee_id (text) , employee_address_id (number) , employee_name (text) , employee_phone (number) | Order_Deliveries : location_code (text) , actual_order_id (number) , delivery_status_code (text) , driver_employee_id (number) , truck_id (text) , delivery_date (number);
[Primary Keys]: products : product_id, addresses : address_id, customers : customer_id, regular_orders : regular_order_id, regular_order_products : actual_order_id, actual_orders : route_id, actual_order_products : location_code, customer_addresses : truck_id, delivery_routes : employee_id
[Foreign Keys]: regular_orders : distributer_id = customers : customer_id | regular_order_products : regular_order_id = regular_orders : regular_order_id | regular_order_products : product_id = products : product_id | actual_orders : regular_order_id = regular_orders : regular_order_id | actual_order_products : actual_order_id = actual_orders : actual_order_id | actual_order_products : product_id = products : product_id | customer_addresses : address_id = addresses : address_id | customer_addresses : customer_id = customers : customer_id | delivery_route_locations : route_id = delivery_routes : route_id | delivery_route_locations : location_address_id = addresses : address_id | employees : employee_address_id = addresses : address_id | order_deliveries : driver_employee_id = employees : employee_id | order_deliveries : location_code = delivery_route_locations : location_code | order_deliveries : actual_order_id = actual_orders : actual_order_id | order_deliveries : truck_id = trucks : truck_id

Question: Find the ids of orders whose status is 'Success'.
SQL: SELECT actual_order_id FROM actual_orders WHERE order_status_code  =  'Success'

Question: Find the name and price of the product that has been ordered the greatest number of times.
SQL: SELECT t1.product_name ,   t1.product_price FROM products AS t1 JOIN regular_order_products AS t2 ON t1.product_id  =  t2.product_id GROUP BY t2.product_id ORDER BY count(*) DESC LIMIT 1

Question: Find the number of customers in total.
SQL: SELECT count(*) FROM customers

Question: How many different payment methods are there?
SQL: SELECT count(DISTINCT payment_method) FROM customers

Question: Show the details of all trucks in the order of their license number.
SQL: SELECT truck_details FROM trucks ORDER BY truck_licence_number

Question: Find the name of the most expensive product.
SQL: SELECT product_name FROM products ORDER BY product_price DESC LIMIT 1

Question: Find the names of customers who are not living in the state of California.
SQL: SELECT customer_name FROM customers EXCEPT 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  =  'California'

Question: List the names and emails of customers who payed by Visa card.
SQL: SELECT customer_email ,  customer_name FROM customers WHERE payment_method  =  'Visa'

Question: Find the names and phone numbers of customers living in California state.
SQL: SELECT t1.customer_name ,  t1.customer_phone 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  =  'California'

Question: Find the states which do not have any employee in their record.
SQL: SELECT state_province_county FROM addresses WHERE address_id NOT IN (SELECT employee_address_id FROM Employees)

Question: List the names, phone numbers, and emails of all customers sorted by their dates of becoming customers.
SQL: SELECT customer_name ,  customer_phone ,  customer_email FROM Customers ORDER BY date_became_customer

Question: Find the name of the first 5 customers.
SQL: SELECT customer_name FROM Customers ORDER BY date_became_customer LIMIT 5

Question: Find the payment method that is used most frequently.
SQL: SELECT payment_method FROM Customers GROUP BY payment_method ORDER BY count(*) DESC LIMIT 1

Question: List the names of all routes in alphabetic order.
SQL: SELECT route_name FROM Delivery_Routes ORDER BY route_name

Question: Find the name of route that has the highest number of deliveries.
SQL: SELECT t1.route_name FROM Delivery_Routes AS t1 JOIN Delivery_Route_Locations AS t2 ON t1.route_id  =  t2.route_id GROUP BY t1.route_id ORDER BY count(*) DESC LIMIT 1

Question: List the state names and the number of customers living in each state.
SQL: SELECT t2.state_province_county ,  count(*) FROM customer_addresses AS t1 JOIN addresses AS t2 ON t1.address_id  =  t2.address_id GROUP BY t2.state_province_county