question
stringlengths
16
224
schema
stringlengths
142
5.86k
query
stringlengths
20
577
What is the customer last name, id and phone number with most number of orders?
Customers: customer_id (INTEGER), customer_first_name (VARCHAR(50)), customer_middle_initial (VARCHAR(1)), customer_last_name (VARCHAR(50)), gender (VARCHAR(1)), email_address (VARCHAR(255)), login_name (VARCHAR(80)), login_password (VARCHAR(20)), phone_number (VARCHAR(255)), town_city (VARCHAR(50)), state_county_province (VARCHAR(50)), country (VARCHAR(50)) Orders: order_id (INTEGER), customer_id (INTEGER), date_order_placed (DATETIME), order_details (VARCHAR(255)) Invoices: invoice_number (INTEGER), order_id (INTEGER), invoice_date (DATETIME) Accounts: account_id (INTEGER), customer_id (INTEGER), date_account_opened (DATETIME), account_name (VARCHAR(50)), other_account_details (VARCHAR(255)) Product_Categories: production_type_code (VARCHAR(15)), product_type_description (VARCHAR(80)), vat_rating (DECIMAL(194)) Products: product_id (INTEGER), parent_product_id (INTEGER), production_type_code (VARCHAR(15)), unit_price (DECIMAL(194)), product_name (VARCHAR(80)), product_color (VARCHAR(20)), product_size (VARCHAR(20)) Financial_Transactions: transaction_id (INTEGER), account_id (INTEGER), invoice_number (INTEGER), transaction_type (VARCHAR(15)), transaction_date (DATETIME), transaction_amount (DECIMAL(194)), transaction_comment (VARCHAR(255)), other_transaction_details (VARCHAR(255)) Order_Items: order_item_id (INTEGER), order_id (INTEGER), product_id (INTEGER), product_quantity (VARCHAR(50)), other_order_item_details (VARCHAR(255)) Invoice_Line_Items: order_item_id (INTEGER), invoice_number (INTEGER), product_id (INTEGER), product_title (VARCHAR(80)), product_quantity (VARCHAR(50)), product_price (DECIMAL(194)), derived_product_cost (DECIMAL(194)), derived_vat_payable (DECIMAL(194)), derived_total_cost (DECIMAL(194))
SELECT T2.customer_last_name , T1.customer_id , T2.phone_number FROM Orders AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id ORDER BY count(*) DESC LIMIT 1
Return the last name, id and phone number of the customer who has made the greatest number of orders.
Customers: customer_id (INTEGER), customer_first_name (VARCHAR(50)), customer_middle_initial (VARCHAR(1)), customer_last_name (VARCHAR(50)), gender (VARCHAR(1)), email_address (VARCHAR(255)), login_name (VARCHAR(80)), login_password (VARCHAR(20)), phone_number (VARCHAR(255)), town_city (VARCHAR(50)), state_county_province (VARCHAR(50)), country (VARCHAR(50)) Orders: order_id (INTEGER), customer_id (INTEGER), date_order_placed (DATETIME), order_details (VARCHAR(255)) Invoices: invoice_number (INTEGER), order_id (INTEGER), invoice_date (DATETIME) Accounts: account_id (INTEGER), customer_id (INTEGER), date_account_opened (DATETIME), account_name (VARCHAR(50)), other_account_details (VARCHAR(255)) Product_Categories: production_type_code (VARCHAR(15)), product_type_description (VARCHAR(80)), vat_rating (DECIMAL(194)) Products: product_id (INTEGER), parent_product_id (INTEGER), production_type_code (VARCHAR(15)), unit_price (DECIMAL(194)), product_name (VARCHAR(80)), product_color (VARCHAR(20)), product_size (VARCHAR(20)) Financial_Transactions: transaction_id (INTEGER), account_id (INTEGER), invoice_number (INTEGER), transaction_type (VARCHAR(15)), transaction_date (DATETIME), transaction_amount (DECIMAL(194)), transaction_comment (VARCHAR(255)), other_transaction_details (VARCHAR(255)) Order_Items: order_item_id (INTEGER), order_id (INTEGER), product_id (INTEGER), product_quantity (VARCHAR(50)), other_order_item_details (VARCHAR(255)) Invoice_Line_Items: order_item_id (INTEGER), invoice_number (INTEGER), product_id (INTEGER), product_title (VARCHAR(80)), product_quantity (VARCHAR(50)), product_price (DECIMAL(194)), derived_product_cost (DECIMAL(194)), derived_vat_payable (DECIMAL(194)), derived_total_cost (DECIMAL(194))
SELECT T2.customer_last_name , T1.customer_id , T2.phone_number FROM Orders AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id ORDER BY count(*) DESC LIMIT 1
Show all product names without an order.
Customers: customer_id (INTEGER), customer_first_name (VARCHAR(50)), customer_middle_initial (VARCHAR(1)), customer_last_name (VARCHAR(50)), gender (VARCHAR(1)), email_address (VARCHAR(255)), login_name (VARCHAR(80)), login_password (VARCHAR(20)), phone_number (VARCHAR(255)), town_city (VARCHAR(50)), state_county_province (VARCHAR(50)), country (VARCHAR(50)) Orders: order_id (INTEGER), customer_id (INTEGER), date_order_placed (DATETIME), order_details (VARCHAR(255)) Invoices: invoice_number (INTEGER), order_id (INTEGER), invoice_date (DATETIME) Accounts: account_id (INTEGER), customer_id (INTEGER), date_account_opened (DATETIME), account_name (VARCHAR(50)), other_account_details (VARCHAR(255)) Product_Categories: production_type_code (VARCHAR(15)), product_type_description (VARCHAR(80)), vat_rating (DECIMAL(194)) Products: product_id (INTEGER), parent_product_id (INTEGER), production_type_code (VARCHAR(15)), unit_price (DECIMAL(194)), product_name (VARCHAR(80)), product_color (VARCHAR(20)), product_size (VARCHAR(20)) Financial_Transactions: transaction_id (INTEGER), account_id (INTEGER), invoice_number (INTEGER), transaction_type (VARCHAR(15)), transaction_date (DATETIME), transaction_amount (DECIMAL(194)), transaction_comment (VARCHAR(255)), other_transaction_details (VARCHAR(255)) Order_Items: order_item_id (INTEGER), order_id (INTEGER), product_id (INTEGER), product_quantity (VARCHAR(50)), other_order_item_details (VARCHAR(255)) Invoice_Line_Items: order_item_id (INTEGER), invoice_number (INTEGER), product_id (INTEGER), product_title (VARCHAR(80)), product_quantity (VARCHAR(50)), product_price (DECIMAL(194)), derived_product_cost (DECIMAL(194)), derived_vat_payable (DECIMAL(194)), derived_total_cost (DECIMAL(194))
SELECT product_name FROM Products EXCEPT SELECT T1.product_name FROM Products AS T1 JOIN Order_items AS T2 ON T1.product_id = T2.product_id
What are the names of products that have never been ordered?
Customers: customer_id (INTEGER), customer_first_name (VARCHAR(50)), customer_middle_initial (VARCHAR(1)), customer_last_name (VARCHAR(50)), gender (VARCHAR(1)), email_address (VARCHAR(255)), login_name (VARCHAR(80)), login_password (VARCHAR(20)), phone_number (VARCHAR(255)), town_city (VARCHAR(50)), state_county_province (VARCHAR(50)), country (VARCHAR(50)) Orders: order_id (INTEGER), customer_id (INTEGER), date_order_placed (DATETIME), order_details (VARCHAR(255)) Invoices: invoice_number (INTEGER), order_id (INTEGER), invoice_date (DATETIME) Accounts: account_id (INTEGER), customer_id (INTEGER), date_account_opened (DATETIME), account_name (VARCHAR(50)), other_account_details (VARCHAR(255)) Product_Categories: production_type_code (VARCHAR(15)), product_type_description (VARCHAR(80)), vat_rating (DECIMAL(194)) Products: product_id (INTEGER), parent_product_id (INTEGER), production_type_code (VARCHAR(15)), unit_price (DECIMAL(194)), product_name (VARCHAR(80)), product_color (VARCHAR(20)), product_size (VARCHAR(20)) Financial_Transactions: transaction_id (INTEGER), account_id (INTEGER), invoice_number (INTEGER), transaction_type (VARCHAR(15)), transaction_date (DATETIME), transaction_amount (DECIMAL(194)), transaction_comment (VARCHAR(255)), other_transaction_details (VARCHAR(255)) Order_Items: order_item_id (INTEGER), order_id (INTEGER), product_id (INTEGER), product_quantity (VARCHAR(50)), other_order_item_details (VARCHAR(255)) Invoice_Line_Items: order_item_id (INTEGER), invoice_number (INTEGER), product_id (INTEGER), product_title (VARCHAR(80)), product_quantity (VARCHAR(50)), product_price (DECIMAL(194)), derived_product_cost (DECIMAL(194)), derived_vat_payable (DECIMAL(194)), derived_total_cost (DECIMAL(194))
SELECT product_name FROM Products EXCEPT SELECT T1.product_name FROM Products AS T1 JOIN Order_items AS T2 ON T1.product_id = T2.product_id
Show all product names and the total quantity ordered for each product name.
Customers: customer_id (INTEGER), customer_first_name (VARCHAR(50)), customer_middle_initial (VARCHAR(1)), customer_last_name (VARCHAR(50)), gender (VARCHAR(1)), email_address (VARCHAR(255)), login_name (VARCHAR(80)), login_password (VARCHAR(20)), phone_number (VARCHAR(255)), town_city (VARCHAR(50)), state_county_province (VARCHAR(50)), country (VARCHAR(50)) Orders: order_id (INTEGER), customer_id (INTEGER), date_order_placed (DATETIME), order_details (VARCHAR(255)) Invoices: invoice_number (INTEGER), order_id (INTEGER), invoice_date (DATETIME) Accounts: account_id (INTEGER), customer_id (INTEGER), date_account_opened (DATETIME), account_name (VARCHAR(50)), other_account_details (VARCHAR(255)) Product_Categories: production_type_code (VARCHAR(15)), product_type_description (VARCHAR(80)), vat_rating (DECIMAL(194)) Products: product_id (INTEGER), parent_product_id (INTEGER), production_type_code (VARCHAR(15)), unit_price (DECIMAL(194)), product_name (VARCHAR(80)), product_color (VARCHAR(20)), product_size (VARCHAR(20)) Financial_Transactions: transaction_id (INTEGER), account_id (INTEGER), invoice_number (INTEGER), transaction_type (VARCHAR(15)), transaction_date (DATETIME), transaction_amount (DECIMAL(194)), transaction_comment (VARCHAR(255)), other_transaction_details (VARCHAR(255)) Order_Items: order_item_id (INTEGER), order_id (INTEGER), product_id (INTEGER), product_quantity (VARCHAR(50)), other_order_item_details (VARCHAR(255)) Invoice_Line_Items: order_item_id (INTEGER), invoice_number (INTEGER), product_id (INTEGER), product_title (VARCHAR(80)), product_quantity (VARCHAR(50)), product_price (DECIMAL(194)), derived_product_cost (DECIMAL(194)), derived_vat_payable (DECIMAL(194)), derived_total_cost (DECIMAL(194))
SELECT T2.product_name , sum(T1.product_quantity) FROM Order_items AS T1 JOIN Products AS T2 ON T1.product_id = T2.product_id GROUP BY T2.product_name
What are the different product names, and what is the sum of quantity ordered for each product?
Customers: customer_id (INTEGER), customer_first_name (VARCHAR(50)), customer_middle_initial (VARCHAR(1)), customer_last_name (VARCHAR(50)), gender (VARCHAR(1)), email_address (VARCHAR(255)), login_name (VARCHAR(80)), login_password (VARCHAR(20)), phone_number (VARCHAR(255)), town_city (VARCHAR(50)), state_county_province (VARCHAR(50)), country (VARCHAR(50)) Orders: order_id (INTEGER), customer_id (INTEGER), date_order_placed (DATETIME), order_details (VARCHAR(255)) Invoices: invoice_number (INTEGER), order_id (INTEGER), invoice_date (DATETIME) Accounts: account_id (INTEGER), customer_id (INTEGER), date_account_opened (DATETIME), account_name (VARCHAR(50)), other_account_details (VARCHAR(255)) Product_Categories: production_type_code (VARCHAR(15)), product_type_description (VARCHAR(80)), vat_rating (DECIMAL(194)) Products: product_id (INTEGER), parent_product_id (INTEGER), production_type_code (VARCHAR(15)), unit_price (DECIMAL(194)), product_name (VARCHAR(80)), product_color (VARCHAR(20)), product_size (VARCHAR(20)) Financial_Transactions: transaction_id (INTEGER), account_id (INTEGER), invoice_number (INTEGER), transaction_type (VARCHAR(15)), transaction_date (DATETIME), transaction_amount (DECIMAL(194)), transaction_comment (VARCHAR(255)), other_transaction_details (VARCHAR(255)) Order_Items: order_item_id (INTEGER), order_id (INTEGER), product_id (INTEGER), product_quantity (VARCHAR(50)), other_order_item_details (VARCHAR(255)) Invoice_Line_Items: order_item_id (INTEGER), invoice_number (INTEGER), product_id (INTEGER), product_title (VARCHAR(80)), product_quantity (VARCHAR(50)), product_price (DECIMAL(194)), derived_product_cost (DECIMAL(194)), derived_vat_payable (DECIMAL(194)), derived_total_cost (DECIMAL(194))
SELECT T2.product_name , sum(T1.product_quantity) FROM Order_items AS T1 JOIN Products AS T2 ON T1.product_id = T2.product_id GROUP BY T2.product_name
Show the order ids and the number of items in each order.
Customers: customer_id (INTEGER), customer_first_name (VARCHAR(50)), customer_middle_initial (VARCHAR(1)), customer_last_name (VARCHAR(50)), gender (VARCHAR(1)), email_address (VARCHAR(255)), login_name (VARCHAR(80)), login_password (VARCHAR(20)), phone_number (VARCHAR(255)), town_city (VARCHAR(50)), state_county_province (VARCHAR(50)), country (VARCHAR(50)) Orders: order_id (INTEGER), customer_id (INTEGER), date_order_placed (DATETIME), order_details (VARCHAR(255)) Invoices: invoice_number (INTEGER), order_id (INTEGER), invoice_date (DATETIME) Accounts: account_id (INTEGER), customer_id (INTEGER), date_account_opened (DATETIME), account_name (VARCHAR(50)), other_account_details (VARCHAR(255)) Product_Categories: production_type_code (VARCHAR(15)), product_type_description (VARCHAR(80)), vat_rating (DECIMAL(194)) Products: product_id (INTEGER), parent_product_id (INTEGER), production_type_code (VARCHAR(15)), unit_price (DECIMAL(194)), product_name (VARCHAR(80)), product_color (VARCHAR(20)), product_size (VARCHAR(20)) Financial_Transactions: transaction_id (INTEGER), account_id (INTEGER), invoice_number (INTEGER), transaction_type (VARCHAR(15)), transaction_date (DATETIME), transaction_amount (DECIMAL(194)), transaction_comment (VARCHAR(255)), other_transaction_details (VARCHAR(255)) Order_Items: order_item_id (INTEGER), order_id (INTEGER), product_id (INTEGER), product_quantity (VARCHAR(50)), other_order_item_details (VARCHAR(255)) Invoice_Line_Items: order_item_id (INTEGER), invoice_number (INTEGER), product_id (INTEGER), product_title (VARCHAR(80)), product_quantity (VARCHAR(50)), product_price (DECIMAL(194)), derived_product_cost (DECIMAL(194)), derived_vat_payable (DECIMAL(194)), derived_total_cost (DECIMAL(194))
SELECT order_id , count(*) FROM Order_items GROUP BY order_id
How many order items correspond to each order id?
Customers: customer_id (INTEGER), customer_first_name (VARCHAR(50)), customer_middle_initial (VARCHAR(1)), customer_last_name (VARCHAR(50)), gender (VARCHAR(1)), email_address (VARCHAR(255)), login_name (VARCHAR(80)), login_password (VARCHAR(20)), phone_number (VARCHAR(255)), town_city (VARCHAR(50)), state_county_province (VARCHAR(50)), country (VARCHAR(50)) Orders: order_id (INTEGER), customer_id (INTEGER), date_order_placed (DATETIME), order_details (VARCHAR(255)) Invoices: invoice_number (INTEGER), order_id (INTEGER), invoice_date (DATETIME) Accounts: account_id (INTEGER), customer_id (INTEGER), date_account_opened (DATETIME), account_name (VARCHAR(50)), other_account_details (VARCHAR(255)) Product_Categories: production_type_code (VARCHAR(15)), product_type_description (VARCHAR(80)), vat_rating (DECIMAL(194)) Products: product_id (INTEGER), parent_product_id (INTEGER), production_type_code (VARCHAR(15)), unit_price (DECIMAL(194)), product_name (VARCHAR(80)), product_color (VARCHAR(20)), product_size (VARCHAR(20)) Financial_Transactions: transaction_id (INTEGER), account_id (INTEGER), invoice_number (INTEGER), transaction_type (VARCHAR(15)), transaction_date (DATETIME), transaction_amount (DECIMAL(194)), transaction_comment (VARCHAR(255)), other_transaction_details (VARCHAR(255)) Order_Items: order_item_id (INTEGER), order_id (INTEGER), product_id (INTEGER), product_quantity (VARCHAR(50)), other_order_item_details (VARCHAR(255)) Invoice_Line_Items: order_item_id (INTEGER), invoice_number (INTEGER), product_id (INTEGER), product_title (VARCHAR(80)), product_quantity (VARCHAR(50)), product_price (DECIMAL(194)), derived_product_cost (DECIMAL(194)), derived_vat_payable (DECIMAL(194)), derived_total_cost (DECIMAL(194))
SELECT order_id , count(*) FROM Order_items GROUP BY order_id
Show the product ids and the number of unique orders containing each product.
Customers: customer_id (INTEGER), customer_first_name (VARCHAR(50)), customer_middle_initial (VARCHAR(1)), customer_last_name (VARCHAR(50)), gender (VARCHAR(1)), email_address (VARCHAR(255)), login_name (VARCHAR(80)), login_password (VARCHAR(20)), phone_number (VARCHAR(255)), town_city (VARCHAR(50)), state_county_province (VARCHAR(50)), country (VARCHAR(50)) Orders: order_id (INTEGER), customer_id (INTEGER), date_order_placed (DATETIME), order_details (VARCHAR(255)) Invoices: invoice_number (INTEGER), order_id (INTEGER), invoice_date (DATETIME) Accounts: account_id (INTEGER), customer_id (INTEGER), date_account_opened (DATETIME), account_name (VARCHAR(50)), other_account_details (VARCHAR(255)) Product_Categories: production_type_code (VARCHAR(15)), product_type_description (VARCHAR(80)), vat_rating (DECIMAL(194)) Products: product_id (INTEGER), parent_product_id (INTEGER), production_type_code (VARCHAR(15)), unit_price (DECIMAL(194)), product_name (VARCHAR(80)), product_color (VARCHAR(20)), product_size (VARCHAR(20)) Financial_Transactions: transaction_id (INTEGER), account_id (INTEGER), invoice_number (INTEGER), transaction_type (VARCHAR(15)), transaction_date (DATETIME), transaction_amount (DECIMAL(194)), transaction_comment (VARCHAR(255)), other_transaction_details (VARCHAR(255)) Order_Items: order_item_id (INTEGER), order_id (INTEGER), product_id (INTEGER), product_quantity (VARCHAR(50)), other_order_item_details (VARCHAR(255)) Invoice_Line_Items: order_item_id (INTEGER), invoice_number (INTEGER), product_id (INTEGER), product_title (VARCHAR(80)), product_quantity (VARCHAR(50)), product_price (DECIMAL(194)), derived_product_cost (DECIMAL(194)), derived_vat_payable (DECIMAL(194)), derived_total_cost (DECIMAL(194))
SELECT product_id , count(DISTINCT order_id) FROM Order_items GROUP BY product_id
How many distinct order ids correspond to each product?
Customers: customer_id (INTEGER), customer_first_name (VARCHAR(50)), customer_middle_initial (VARCHAR(1)), customer_last_name (VARCHAR(50)), gender (VARCHAR(1)), email_address (VARCHAR(255)), login_name (VARCHAR(80)), login_password (VARCHAR(20)), phone_number (VARCHAR(255)), town_city (VARCHAR(50)), state_county_province (VARCHAR(50)), country (VARCHAR(50)) Orders: order_id (INTEGER), customer_id (INTEGER), date_order_placed (DATETIME), order_details (VARCHAR(255)) Invoices: invoice_number (INTEGER), order_id (INTEGER), invoice_date (DATETIME) Accounts: account_id (INTEGER), customer_id (INTEGER), date_account_opened (DATETIME), account_name (VARCHAR(50)), other_account_details (VARCHAR(255)) Product_Categories: production_type_code (VARCHAR(15)), product_type_description (VARCHAR(80)), vat_rating (DECIMAL(194)) Products: product_id (INTEGER), parent_product_id (INTEGER), production_type_code (VARCHAR(15)), unit_price (DECIMAL(194)), product_name (VARCHAR(80)), product_color (VARCHAR(20)), product_size (VARCHAR(20)) Financial_Transactions: transaction_id (INTEGER), account_id (INTEGER), invoice_number (INTEGER), transaction_type (VARCHAR(15)), transaction_date (DATETIME), transaction_amount (DECIMAL(194)), transaction_comment (VARCHAR(255)), other_transaction_details (VARCHAR(255)) Order_Items: order_item_id (INTEGER), order_id (INTEGER), product_id (INTEGER), product_quantity (VARCHAR(50)), other_order_item_details (VARCHAR(255)) Invoice_Line_Items: order_item_id (INTEGER), invoice_number (INTEGER), product_id (INTEGER), product_title (VARCHAR(80)), product_quantity (VARCHAR(50)), product_price (DECIMAL(194)), derived_product_cost (DECIMAL(194)), derived_vat_payable (DECIMAL(194)), derived_total_cost (DECIMAL(194))
SELECT product_id , count(DISTINCT order_id) FROM Order_items GROUP BY product_id
Show all product names and the number of customers having an order on each product.
Customers: customer_id (INTEGER), customer_first_name (VARCHAR(50)), customer_middle_initial (VARCHAR(1)), customer_last_name (VARCHAR(50)), gender (VARCHAR(1)), email_address (VARCHAR(255)), login_name (VARCHAR(80)), login_password (VARCHAR(20)), phone_number (VARCHAR(255)), town_city (VARCHAR(50)), state_county_province (VARCHAR(50)), country (VARCHAR(50)) Orders: order_id (INTEGER), customer_id (INTEGER), date_order_placed (DATETIME), order_details (VARCHAR(255)) Invoices: invoice_number (INTEGER), order_id (INTEGER), invoice_date (DATETIME) Accounts: account_id (INTEGER), customer_id (INTEGER), date_account_opened (DATETIME), account_name (VARCHAR(50)), other_account_details (VARCHAR(255)) Product_Categories: production_type_code (VARCHAR(15)), product_type_description (VARCHAR(80)), vat_rating (DECIMAL(194)) Products: product_id (INTEGER), parent_product_id (INTEGER), production_type_code (VARCHAR(15)), unit_price (DECIMAL(194)), product_name (VARCHAR(80)), product_color (VARCHAR(20)), product_size (VARCHAR(20)) Financial_Transactions: transaction_id (INTEGER), account_id (INTEGER), invoice_number (INTEGER), transaction_type (VARCHAR(15)), transaction_date (DATETIME), transaction_amount (DECIMAL(194)), transaction_comment (VARCHAR(255)), other_transaction_details (VARCHAR(255)) Order_Items: order_item_id (INTEGER), order_id (INTEGER), product_id (INTEGER), product_quantity (VARCHAR(50)), other_order_item_details (VARCHAR(255)) Invoice_Line_Items: order_item_id (INTEGER), invoice_number (INTEGER), product_id (INTEGER), product_title (VARCHAR(80)), product_quantity (VARCHAR(50)), product_price (DECIMAL(194)), derived_product_cost (DECIMAL(194)), derived_vat_payable (DECIMAL(194)), derived_total_cost (DECIMAL(194))
SELECT T2.product_name , count(*) FROM Order_items AS T1 JOIN Products AS T2 ON T1.product_id = T2.product_id JOIN Orders AS T3 ON T3.order_id = T1.order_id GROUP BY T2.product_name
What are teh names of the different products, as well as the number of customers who have ordered each product.
Customers: customer_id (INTEGER), customer_first_name (VARCHAR(50)), customer_middle_initial (VARCHAR(1)), customer_last_name (VARCHAR(50)), gender (VARCHAR(1)), email_address (VARCHAR(255)), login_name (VARCHAR(80)), login_password (VARCHAR(20)), phone_number (VARCHAR(255)), town_city (VARCHAR(50)), state_county_province (VARCHAR(50)), country (VARCHAR(50)) Orders: order_id (INTEGER), customer_id (INTEGER), date_order_placed (DATETIME), order_details (VARCHAR(255)) Invoices: invoice_number (INTEGER), order_id (INTEGER), invoice_date (DATETIME) Accounts: account_id (INTEGER), customer_id (INTEGER), date_account_opened (DATETIME), account_name (VARCHAR(50)), other_account_details (VARCHAR(255)) Product_Categories: production_type_code (VARCHAR(15)), product_type_description (VARCHAR(80)), vat_rating (DECIMAL(194)) Products: product_id (INTEGER), parent_product_id (INTEGER), production_type_code (VARCHAR(15)), unit_price (DECIMAL(194)), product_name (VARCHAR(80)), product_color (VARCHAR(20)), product_size (VARCHAR(20)) Financial_Transactions: transaction_id (INTEGER), account_id (INTEGER), invoice_number (INTEGER), transaction_type (VARCHAR(15)), transaction_date (DATETIME), transaction_amount (DECIMAL(194)), transaction_comment (VARCHAR(255)), other_transaction_details (VARCHAR(255)) Order_Items: order_item_id (INTEGER), order_id (INTEGER), product_id (INTEGER), product_quantity (VARCHAR(50)), other_order_item_details (VARCHAR(255)) Invoice_Line_Items: order_item_id (INTEGER), invoice_number (INTEGER), product_id (INTEGER), product_title (VARCHAR(80)), product_quantity (VARCHAR(50)), product_price (DECIMAL(194)), derived_product_cost (DECIMAL(194)), derived_vat_payable (DECIMAL(194)), derived_total_cost (DECIMAL(194))
SELECT T2.product_name , count(*) FROM Order_items AS T1 JOIN Products AS T2 ON T1.product_id = T2.product_id JOIN Orders AS T3 ON T3.order_id = T1.order_id GROUP BY T2.product_name
Show order ids and the number of products in each order.
Customers: customer_id (INTEGER), customer_first_name (VARCHAR(50)), customer_middle_initial (VARCHAR(1)), customer_last_name (VARCHAR(50)), gender (VARCHAR(1)), email_address (VARCHAR(255)), login_name (VARCHAR(80)), login_password (VARCHAR(20)), phone_number (VARCHAR(255)), town_city (VARCHAR(50)), state_county_province (VARCHAR(50)), country (VARCHAR(50)) Orders: order_id (INTEGER), customer_id (INTEGER), date_order_placed (DATETIME), order_details (VARCHAR(255)) Invoices: invoice_number (INTEGER), order_id (INTEGER), invoice_date (DATETIME) Accounts: account_id (INTEGER), customer_id (INTEGER), date_account_opened (DATETIME), account_name (VARCHAR(50)), other_account_details (VARCHAR(255)) Product_Categories: production_type_code (VARCHAR(15)), product_type_description (VARCHAR(80)), vat_rating (DECIMAL(194)) Products: product_id (INTEGER), parent_product_id (INTEGER), production_type_code (VARCHAR(15)), unit_price (DECIMAL(194)), product_name (VARCHAR(80)), product_color (VARCHAR(20)), product_size (VARCHAR(20)) Financial_Transactions: transaction_id (INTEGER), account_id (INTEGER), invoice_number (INTEGER), transaction_type (VARCHAR(15)), transaction_date (DATETIME), transaction_amount (DECIMAL(194)), transaction_comment (VARCHAR(255)), other_transaction_details (VARCHAR(255)) Order_Items: order_item_id (INTEGER), order_id (INTEGER), product_id (INTEGER), product_quantity (VARCHAR(50)), other_order_item_details (VARCHAR(255)) Invoice_Line_Items: order_item_id (INTEGER), invoice_number (INTEGER), product_id (INTEGER), product_title (VARCHAR(80)), product_quantity (VARCHAR(50)), product_price (DECIMAL(194)), derived_product_cost (DECIMAL(194)), derived_vat_payable (DECIMAL(194)), derived_total_cost (DECIMAL(194))
SELECT order_id , count(DISTINCT product_id) FROM Order_items GROUP BY order_id
How many different products correspond to each order id?
Customers: customer_id (INTEGER), customer_first_name (VARCHAR(50)), customer_middle_initial (VARCHAR(1)), customer_last_name (VARCHAR(50)), gender (VARCHAR(1)), email_address (VARCHAR(255)), login_name (VARCHAR(80)), login_password (VARCHAR(20)), phone_number (VARCHAR(255)), town_city (VARCHAR(50)), state_county_province (VARCHAR(50)), country (VARCHAR(50)) Orders: order_id (INTEGER), customer_id (INTEGER), date_order_placed (DATETIME), order_details (VARCHAR(255)) Invoices: invoice_number (INTEGER), order_id (INTEGER), invoice_date (DATETIME) Accounts: account_id (INTEGER), customer_id (INTEGER), date_account_opened (DATETIME), account_name (VARCHAR(50)), other_account_details (VARCHAR(255)) Product_Categories: production_type_code (VARCHAR(15)), product_type_description (VARCHAR(80)), vat_rating (DECIMAL(194)) Products: product_id (INTEGER), parent_product_id (INTEGER), production_type_code (VARCHAR(15)), unit_price (DECIMAL(194)), product_name (VARCHAR(80)), product_color (VARCHAR(20)), product_size (VARCHAR(20)) Financial_Transactions: transaction_id (INTEGER), account_id (INTEGER), invoice_number (INTEGER), transaction_type (VARCHAR(15)), transaction_date (DATETIME), transaction_amount (DECIMAL(194)), transaction_comment (VARCHAR(255)), other_transaction_details (VARCHAR(255)) Order_Items: order_item_id (INTEGER), order_id (INTEGER), product_id (INTEGER), product_quantity (VARCHAR(50)), other_order_item_details (VARCHAR(255)) Invoice_Line_Items: order_item_id (INTEGER), invoice_number (INTEGER), product_id (INTEGER), product_title (VARCHAR(80)), product_quantity (VARCHAR(50)), product_price (DECIMAL(194)), derived_product_cost (DECIMAL(194)), derived_vat_payable (DECIMAL(194)), derived_total_cost (DECIMAL(194))
SELECT order_id , count(DISTINCT product_id) FROM Order_items GROUP BY order_id
Show order ids and the total quantity in each order.
Customers: customer_id (INTEGER), customer_first_name (VARCHAR(50)), customer_middle_initial (VARCHAR(1)), customer_last_name (VARCHAR(50)), gender (VARCHAR(1)), email_address (VARCHAR(255)), login_name (VARCHAR(80)), login_password (VARCHAR(20)), phone_number (VARCHAR(255)), town_city (VARCHAR(50)), state_county_province (VARCHAR(50)), country (VARCHAR(50)) Orders: order_id (INTEGER), customer_id (INTEGER), date_order_placed (DATETIME), order_details (VARCHAR(255)) Invoices: invoice_number (INTEGER), order_id (INTEGER), invoice_date (DATETIME) Accounts: account_id (INTEGER), customer_id (INTEGER), date_account_opened (DATETIME), account_name (VARCHAR(50)), other_account_details (VARCHAR(255)) Product_Categories: production_type_code (VARCHAR(15)), product_type_description (VARCHAR(80)), vat_rating (DECIMAL(194)) Products: product_id (INTEGER), parent_product_id (INTEGER), production_type_code (VARCHAR(15)), unit_price (DECIMAL(194)), product_name (VARCHAR(80)), product_color (VARCHAR(20)), product_size (VARCHAR(20)) Financial_Transactions: transaction_id (INTEGER), account_id (INTEGER), invoice_number (INTEGER), transaction_type (VARCHAR(15)), transaction_date (DATETIME), transaction_amount (DECIMAL(194)), transaction_comment (VARCHAR(255)), other_transaction_details (VARCHAR(255)) Order_Items: order_item_id (INTEGER), order_id (INTEGER), product_id (INTEGER), product_quantity (VARCHAR(50)), other_order_item_details (VARCHAR(255)) Invoice_Line_Items: order_item_id (INTEGER), invoice_number (INTEGER), product_id (INTEGER), product_title (VARCHAR(80)), product_quantity (VARCHAR(50)), product_price (DECIMAL(194)), derived_product_cost (DECIMAL(194)), derived_vat_payable (DECIMAL(194)), derived_total_cost (DECIMAL(194))
SELECT order_id , sum(product_quantity) FROM Order_items GROUP BY order_id
Give the order ids for all orders, as well as the total product quantity in each.
Customers: customer_id (INTEGER), customer_first_name (VARCHAR(50)), customer_middle_initial (VARCHAR(1)), customer_last_name (VARCHAR(50)), gender (VARCHAR(1)), email_address (VARCHAR(255)), login_name (VARCHAR(80)), login_password (VARCHAR(20)), phone_number (VARCHAR(255)), town_city (VARCHAR(50)), state_county_province (VARCHAR(50)), country (VARCHAR(50)) Orders: order_id (INTEGER), customer_id (INTEGER), date_order_placed (DATETIME), order_details (VARCHAR(255)) Invoices: invoice_number (INTEGER), order_id (INTEGER), invoice_date (DATETIME) Accounts: account_id (INTEGER), customer_id (INTEGER), date_account_opened (DATETIME), account_name (VARCHAR(50)), other_account_details (VARCHAR(255)) Product_Categories: production_type_code (VARCHAR(15)), product_type_description (VARCHAR(80)), vat_rating (DECIMAL(194)) Products: product_id (INTEGER), parent_product_id (INTEGER), production_type_code (VARCHAR(15)), unit_price (DECIMAL(194)), product_name (VARCHAR(80)), product_color (VARCHAR(20)), product_size (VARCHAR(20)) Financial_Transactions: transaction_id (INTEGER), account_id (INTEGER), invoice_number (INTEGER), transaction_type (VARCHAR(15)), transaction_date (DATETIME), transaction_amount (DECIMAL(194)), transaction_comment (VARCHAR(255)), other_transaction_details (VARCHAR(255)) Order_Items: order_item_id (INTEGER), order_id (INTEGER), product_id (INTEGER), product_quantity (VARCHAR(50)), other_order_item_details (VARCHAR(255)) Invoice_Line_Items: order_item_id (INTEGER), invoice_number (INTEGER), product_id (INTEGER), product_title (VARCHAR(80)), product_quantity (VARCHAR(50)), product_price (DECIMAL(194)), derived_product_cost (DECIMAL(194)), derived_vat_payable (DECIMAL(194)), derived_total_cost (DECIMAL(194))
SELECT order_id , sum(product_quantity) FROM Order_items GROUP BY order_id
How many products were not included in any order?
Customers: customer_id (INTEGER), customer_first_name (VARCHAR(50)), customer_middle_initial (VARCHAR(1)), customer_last_name (VARCHAR(50)), gender (VARCHAR(1)), email_address (VARCHAR(255)), login_name (VARCHAR(80)), login_password (VARCHAR(20)), phone_number (VARCHAR(255)), town_city (VARCHAR(50)), state_county_province (VARCHAR(50)), country (VARCHAR(50)) Orders: order_id (INTEGER), customer_id (INTEGER), date_order_placed (DATETIME), order_details (VARCHAR(255)) Invoices: invoice_number (INTEGER), order_id (INTEGER), invoice_date (DATETIME) Accounts: account_id (INTEGER), customer_id (INTEGER), date_account_opened (DATETIME), account_name (VARCHAR(50)), other_account_details (VARCHAR(255)) Product_Categories: production_type_code (VARCHAR(15)), product_type_description (VARCHAR(80)), vat_rating (DECIMAL(194)) Products: product_id (INTEGER), parent_product_id (INTEGER), production_type_code (VARCHAR(15)), unit_price (DECIMAL(194)), product_name (VARCHAR(80)), product_color (VARCHAR(20)), product_size (VARCHAR(20)) Financial_Transactions: transaction_id (INTEGER), account_id (INTEGER), invoice_number (INTEGER), transaction_type (VARCHAR(15)), transaction_date (DATETIME), transaction_amount (DECIMAL(194)), transaction_comment (VARCHAR(255)), other_transaction_details (VARCHAR(255)) Order_Items: order_item_id (INTEGER), order_id (INTEGER), product_id (INTEGER), product_quantity (VARCHAR(50)), other_order_item_details (VARCHAR(255)) Invoice_Line_Items: order_item_id (INTEGER), invoice_number (INTEGER), product_id (INTEGER), product_title (VARCHAR(80)), product_quantity (VARCHAR(50)), product_price (DECIMAL(194)), derived_product_cost (DECIMAL(194)), derived_vat_payable (DECIMAL(194)), derived_total_cost (DECIMAL(194))
SELECT count(*) FROM products WHERE product_id NOT IN ( SELECT product_id FROM Order_items )
Count the number of products that were never ordered.
Customers: customer_id (INTEGER), customer_first_name (VARCHAR(50)), customer_middle_initial (VARCHAR(1)), customer_last_name (VARCHAR(50)), gender (VARCHAR(1)), email_address (VARCHAR(255)), login_name (VARCHAR(80)), login_password (VARCHAR(20)), phone_number (VARCHAR(255)), town_city (VARCHAR(50)), state_county_province (VARCHAR(50)), country (VARCHAR(50)) Orders: order_id (INTEGER), customer_id (INTEGER), date_order_placed (DATETIME), order_details (VARCHAR(255)) Invoices: invoice_number (INTEGER), order_id (INTEGER), invoice_date (DATETIME) Accounts: account_id (INTEGER), customer_id (INTEGER), date_account_opened (DATETIME), account_name (VARCHAR(50)), other_account_details (VARCHAR(255)) Product_Categories: production_type_code (VARCHAR(15)), product_type_description (VARCHAR(80)), vat_rating (DECIMAL(194)) Products: product_id (INTEGER), parent_product_id (INTEGER), production_type_code (VARCHAR(15)), unit_price (DECIMAL(194)), product_name (VARCHAR(80)), product_color (VARCHAR(20)), product_size (VARCHAR(20)) Financial_Transactions: transaction_id (INTEGER), account_id (INTEGER), invoice_number (INTEGER), transaction_type (VARCHAR(15)), transaction_date (DATETIME), transaction_amount (DECIMAL(194)), transaction_comment (VARCHAR(255)), other_transaction_details (VARCHAR(255)) Order_Items: order_item_id (INTEGER), order_id (INTEGER), product_id (INTEGER), product_quantity (VARCHAR(50)), other_order_item_details (VARCHAR(255)) Invoice_Line_Items: order_item_id (INTEGER), invoice_number (INTEGER), product_id (INTEGER), product_title (VARCHAR(80)), product_quantity (VARCHAR(50)), product_price (DECIMAL(194)), derived_product_cost (DECIMAL(194)), derived_vat_payable (DECIMAL(194)), derived_total_cost (DECIMAL(194))
SELECT count(*) FROM products WHERE product_id NOT IN ( SELECT product_id FROM Order_items )
How many churches opened before 1850 are there?
people: People_ID (INT), Name (TEXT), Country (TEXT), Is_Male (TEXT), Age (INT) church: Church_ID (INT), Name (TEXT), Organized_by (TEXT), Open_Date (INT), Continuation_of (TEXT) wedding: Church_ID (INT), Male_ID (INT), Female_ID (INT), Year (INT)
SELECT count(*) FROM Church WHERE Open_Date < 1850
Show the name, open date, and organizer for all churches.
people: People_ID (INT), Name (TEXT), Country (TEXT), Is_Male (TEXT), Age (INT) church: Church_ID (INT), Name (TEXT), Organized_by (TEXT), Open_Date (INT), Continuation_of (TEXT) wedding: Church_ID (INT), Male_ID (INT), Female_ID (INT), Year (INT)
SELECT name , open_date , organized_by FROM Church
List all church names in descending order of opening date.
people: People_ID (INT), Name (TEXT), Country (TEXT), Is_Male (TEXT), Age (INT) church: Church_ID (INT), Name (TEXT), Organized_by (TEXT), Open_Date (INT), Continuation_of (TEXT) wedding: Church_ID (INT), Male_ID (INT), Female_ID (INT), Year (INT)
SELECT name FROM church ORDER BY open_date DESC
Show the opening year in whcih at least two churches opened.
people: People_ID (INT), Name (TEXT), Country (TEXT), Is_Male (TEXT), Age (INT) church: Church_ID (INT), Name (TEXT), Organized_by (TEXT), Open_Date (INT), Continuation_of (TEXT) wedding: Church_ID (INT), Male_ID (INT), Female_ID (INT), Year (INT)
SELECT open_date FROM church GROUP BY open_date HAVING count(*) >= 2
Show the organizer and name for churches that opened between 1830 and 1840.
people: People_ID (INT), Name (TEXT), Country (TEXT), Is_Male (TEXT), Age (INT) church: Church_ID (INT), Name (TEXT), Organized_by (TEXT), Open_Date (INT), Continuation_of (TEXT) wedding: Church_ID (INT), Male_ID (INT), Female_ID (INT), Year (INT)
SELECT organized_by , name FROM church WHERE open_date BETWEEN 1830 AND 1840
Show all opening years and the number of churches that opened in that year.
people: People_ID (INT), Name (TEXT), Country (TEXT), Is_Male (TEXT), Age (INT) church: Church_ID (INT), Name (TEXT), Organized_by (TEXT), Open_Date (INT), Continuation_of (TEXT) wedding: Church_ID (INT), Male_ID (INT), Female_ID (INT), Year (INT)
SELECT open_date , count(*) FROM church GROUP BY open_date
Show the name and opening year for three churches that opened most recently.
people: People_ID (INT), Name (TEXT), Country (TEXT), Is_Male (TEXT), Age (INT) church: Church_ID (INT), Name (TEXT), Organized_by (TEXT), Open_Date (INT), Continuation_of (TEXT) wedding: Church_ID (INT), Male_ID (INT), Female_ID (INT), Year (INT)
SELECT name , open_date FROM church ORDER BY open_date DESC LIMIT 3
How many female people are older than 30 in our record?
people: People_ID (INT), Name (TEXT), Country (TEXT), Is_Male (TEXT), Age (INT) church: Church_ID (INT), Name (TEXT), Organized_by (TEXT), Open_Date (INT), Continuation_of (TEXT) wedding: Church_ID (INT), Male_ID (INT), Female_ID (INT), Year (INT)
SELECT count(*) FROM people WHERE is_male = 'F' AND age > 30
Show the country where people older than 30 and younger than 25 are from.
people: People_ID (INT), Name (TEXT), Country (TEXT), Is_Male (TEXT), Age (INT) church: Church_ID (INT), Name (TEXT), Organized_by (TEXT), Open_Date (INT), Continuation_of (TEXT) wedding: Church_ID (INT), Male_ID (INT), Female_ID (INT), Year (INT)
SELECT country FROM people WHERE age < 25 INTERSECT SELECT country FROM people WHERE age > 30
Show the minimum, maximum, and average age for all people.
people: People_ID (INT), Name (TEXT), Country (TEXT), Is_Male (TEXT), Age (INT) church: Church_ID (INT), Name (TEXT), Organized_by (TEXT), Open_Date (INT), Continuation_of (TEXT) wedding: Church_ID (INT), Male_ID (INT), Female_ID (INT), Year (INT)
SELECT min(age) , max(age) , avg(age) FROM people
Show the name and country for all people whose age is smaller than the average.
people: People_ID (INT), Name (TEXT), Country (TEXT), Is_Male (TEXT), Age (INT) church: Church_ID (INT), Name (TEXT), Organized_by (TEXT), Open_Date (INT), Continuation_of (TEXT) wedding: Church_ID (INT), Male_ID (INT), Female_ID (INT), Year (INT)
SELECT name , country FROM people WHERE age < (SELECT avg(age) FROM people)
Show the pair of male and female names in all weddings after year 2014
people: People_ID (INT), Name (TEXT), Country (TEXT), Is_Male (TEXT), Age (INT) church: Church_ID (INT), Name (TEXT), Organized_by (TEXT), Open_Date (INT), Continuation_of (TEXT) wedding: Church_ID (INT), Male_ID (INT), Female_ID (INT), Year (INT)
SELECT T2.name , T3.name FROM wedding AS T1 JOIN people AS T2 ON T1.male_id = T2.people_id JOIN people AS T3 ON T1.female_id = T3.people_id WHERE T1.year > 2014
Show the name and age for all male people who don't have a wedding.
people: People_ID (INT), Name (TEXT), Country (TEXT), Is_Male (TEXT), Age (INT) church: Church_ID (INT), Name (TEXT), Organized_by (TEXT), Open_Date (INT), Continuation_of (TEXT) wedding: Church_ID (INT), Male_ID (INT), Female_ID (INT), Year (INT)
SELECT name , age FROM people WHERE is_male = 'T' AND people_id NOT IN (SELECT male_id FROM wedding)
Show all church names except for those that had a wedding in year 2015.
people: People_ID (INT), Name (TEXT), Country (TEXT), Is_Male (TEXT), Age (INT) church: Church_ID (INT), Name (TEXT), Organized_by (TEXT), Open_Date (INT), Continuation_of (TEXT) wedding: Church_ID (INT), Male_ID (INT), Female_ID (INT), Year (INT)
SELECT name FROM church EXCEPT SELECT T1.name FROM church AS T1 JOIN wedding AS T2 ON T1.church_id = T2.church_id WHERE T2.year = 2015
Show all church names that have hosted least two weddings.
people: People_ID (INT), Name (TEXT), Country (TEXT), Is_Male (TEXT), Age (INT) church: Church_ID (INT), Name (TEXT), Organized_by (TEXT), Open_Date (INT), Continuation_of (TEXT) wedding: Church_ID (INT), Male_ID (INT), Female_ID (INT), Year (INT)
SELECT T1.name FROM church AS T1 JOIN wedding AS T2 ON T1.church_id = T2.church_id GROUP BY T1.church_id HAVING count(*) >= 2
Show the names for all females from Canada having a wedding in year 2016.
people: People_ID (INT), Name (TEXT), Country (TEXT), Is_Male (TEXT), Age (INT) church: Church_ID (INT), Name (TEXT), Organized_by (TEXT), Open_Date (INT), Continuation_of (TEXT) wedding: Church_ID (INT), Male_ID (INT), Female_ID (INT), Year (INT)
SELECT T2.name FROM wedding AS T1 JOIN people AS T2 ON T1.female_id = T2.people_id WHERE T1.year = 2016 AND T2.is_male = 'F' AND T2.country = 'Canada'
How many weddings are there in year 2016?
people: People_ID (INT), Name (TEXT), Country (TEXT), Is_Male (TEXT), Age (INT) church: Church_ID (INT), Name (TEXT), Organized_by (TEXT), Open_Date (INT), Continuation_of (TEXT) wedding: Church_ID (INT), Male_ID (INT), Female_ID (INT), Year (INT)
SELECT count(*) FROM wedding WHERE YEAR = 2016
Show the church names for the weddings of all people older than 30.
people: People_ID (INT), Name (TEXT), Country (TEXT), Is_Male (TEXT), Age (INT) church: Church_ID (INT), Name (TEXT), Organized_by (TEXT), Open_Date (INT), Continuation_of (TEXT) wedding: Church_ID (INT), Male_ID (INT), Female_ID (INT), Year (INT)
SELECT T4.name FROM wedding AS T1 JOIN people AS T2 ON T1.male_id = T2.people_id JOIN people AS T3 ON T1.female_id = T3.people_id JOIN church AS T4 ON T4.church_id = T1.church_id WHERE T2.age > 30 OR T3.age > 30
Show all countries and the number of people from each country.
people: People_ID (INT), Name (TEXT), Country (TEXT), Is_Male (TEXT), Age (INT) church: Church_ID (INT), Name (TEXT), Organized_by (TEXT), Open_Date (INT), Continuation_of (TEXT) wedding: Church_ID (INT), Male_ID (INT), Female_ID (INT), Year (INT)
SELECT country , count(*) FROM people GROUP BY country
How many churches have a wedding in year 2016?
people: People_ID (INT), Name (TEXT), Country (TEXT), Is_Male (TEXT), Age (INT) church: Church_ID (INT), Name (TEXT), Organized_by (TEXT), Open_Date (INT), Continuation_of (TEXT) wedding: Church_ID (INT), Male_ID (INT), Female_ID (INT), Year (INT)
SELECT COUNT (DISTINCT church_id) FROM wedding WHERE YEAR = 2016
How many artists do we have?
artist: Artist_ID (INT), Name (TEXT), Country (TEXT), Year_Join (INT), Age (INT) exhibition: Exhibition_ID (INT), Year (INT), Theme (TEXT), Artist_ID (INT), Ticket_Price (REAL) exhibition_record: Exhibition_ID (INT), Date (TEXT), Attendance (INT)
SELECT count(*) FROM artist
Count the number of artists.
artist: Artist_ID (INT), Name (TEXT), Country (TEXT), Year_Join (INT), Age (INT) exhibition: Exhibition_ID (INT), Year (INT), Theme (TEXT), Artist_ID (INT), Ticket_Price (REAL) exhibition_record: Exhibition_ID (INT), Date (TEXT), Attendance (INT)
SELECT count(*) FROM artist
Show all artist name, age, and country ordered by the yeared they joined.
artist: Artist_ID (INT), Name (TEXT), Country (TEXT), Year_Join (INT), Age (INT) exhibition: Exhibition_ID (INT), Year (INT), Theme (TEXT), Artist_ID (INT), Ticket_Price (REAL) exhibition_record: Exhibition_ID (INT), Date (TEXT), Attendance (INT)
SELECT name , age , country FROM artist ORDER BY Year_Join
What are the names, ages, and countries of artists, sorted by the year they joined?
artist: Artist_ID (INT), Name (TEXT), Country (TEXT), Year_Join (INT), Age (INT) exhibition: Exhibition_ID (INT), Year (INT), Theme (TEXT), Artist_ID (INT), Ticket_Price (REAL) exhibition_record: Exhibition_ID (INT), Date (TEXT), Attendance (INT)
SELECT name , age , country FROM artist ORDER BY Year_Join
What are all distinct country for artists?
artist: Artist_ID (INT), Name (TEXT), Country (TEXT), Year_Join (INT), Age (INT) exhibition: Exhibition_ID (INT), Year (INT), Theme (TEXT), Artist_ID (INT), Ticket_Price (REAL) exhibition_record: Exhibition_ID (INT), Date (TEXT), Attendance (INT)
SELECT DISTINCT country FROM artist
Return the different countries for artists.
artist: Artist_ID (INT), Name (TEXT), Country (TEXT), Year_Join (INT), Age (INT) exhibition: Exhibition_ID (INT), Year (INT), Theme (TEXT), Artist_ID (INT), Ticket_Price (REAL) exhibition_record: Exhibition_ID (INT), Date (TEXT), Attendance (INT)
SELECT DISTINCT country FROM artist
Show all artist names and the year joined who are not from United States.
artist: Artist_ID (INT), Name (TEXT), Country (TEXT), Year_Join (INT), Age (INT) exhibition: Exhibition_ID (INT), Year (INT), Theme (TEXT), Artist_ID (INT), Ticket_Price (REAL) exhibition_record: Exhibition_ID (INT), Date (TEXT), Attendance (INT)
SELECT name , year_join FROM artist WHERE country != 'United States'
What are the names and year of joining for artists that do not have the country "United States"?
artist: Artist_ID (INT), Name (TEXT), Country (TEXT), Year_Join (INT), Age (INT) exhibition: Exhibition_ID (INT), Year (INT), Theme (TEXT), Artist_ID (INT), Ticket_Price (REAL) exhibition_record: Exhibition_ID (INT), Date (TEXT), Attendance (INT)
SELECT name , year_join FROM artist WHERE country != 'United States'
How many artists are above age 46 and joined after 1990?
artist: Artist_ID (INT), Name (TEXT), Country (TEXT), Year_Join (INT), Age (INT) exhibition: Exhibition_ID (INT), Year (INT), Theme (TEXT), Artist_ID (INT), Ticket_Price (REAL) exhibition_record: Exhibition_ID (INT), Date (TEXT), Attendance (INT)
SELECT count(*) FROM artist WHERE age > 46 AND year_join > 1990
Count the number of artists who are older than 46 and joined after 1990.
artist: Artist_ID (INT), Name (TEXT), Country (TEXT), Year_Join (INT), Age (INT) exhibition: Exhibition_ID (INT), Year (INT), Theme (TEXT), Artist_ID (INT), Ticket_Price (REAL) exhibition_record: Exhibition_ID (INT), Date (TEXT), Attendance (INT)
SELECT count(*) FROM artist WHERE age > 46 AND year_join > 1990
What is the average and minimum age of all artists from United States.
artist: Artist_ID (INT), Name (TEXT), Country (TEXT), Year_Join (INT), Age (INT) exhibition: Exhibition_ID (INT), Year (INT), Theme (TEXT), Artist_ID (INT), Ticket_Price (REAL) exhibition_record: Exhibition_ID (INT), Date (TEXT), Attendance (INT)
SELECT avg(age) , min(age) FROM artist WHERE country = 'United States'
Return the average and minimum ages across artists from the United States.
artist: Artist_ID (INT), Name (TEXT), Country (TEXT), Year_Join (INT), Age (INT) exhibition: Exhibition_ID (INT), Year (INT), Theme (TEXT), Artist_ID (INT), Ticket_Price (REAL) exhibition_record: Exhibition_ID (INT), Date (TEXT), Attendance (INT)
SELECT avg(age) , min(age) FROM artist WHERE country = 'United States'
What is the name of the artist who joined latest?
artist: Artist_ID (INT), Name (TEXT), Country (TEXT), Year_Join (INT), Age (INT) exhibition: Exhibition_ID (INT), Year (INT), Theme (TEXT), Artist_ID (INT), Ticket_Price (REAL) exhibition_record: Exhibition_ID (INT), Date (TEXT), Attendance (INT)
SELECT name FROM artist ORDER BY year_join DESC LIMIT 1
Return the name of the artist who has the latest join year.
artist: Artist_ID (INT), Name (TEXT), Country (TEXT), Year_Join (INT), Age (INT) exhibition: Exhibition_ID (INT), Year (INT), Theme (TEXT), Artist_ID (INT), Ticket_Price (REAL) exhibition_record: Exhibition_ID (INT), Date (TEXT), Attendance (INT)
SELECT name FROM artist ORDER BY year_join DESC LIMIT 1
How many exhibition are there in year 2005 or after?
artist: Artist_ID (INT), Name (TEXT), Country (TEXT), Year_Join (INT), Age (INT) exhibition: Exhibition_ID (INT), Year (INT), Theme (TEXT), Artist_ID (INT), Ticket_Price (REAL) exhibition_record: Exhibition_ID (INT), Date (TEXT), Attendance (INT)
SELECT count(*) FROM exhibition WHERE YEAR >= 2005
Count the number of exhibitions that happened in or after 2005.
artist: Artist_ID (INT), Name (TEXT), Country (TEXT), Year_Join (INT), Age (INT) exhibition: Exhibition_ID (INT), Year (INT), Theme (TEXT), Artist_ID (INT), Ticket_Price (REAL) exhibition_record: Exhibition_ID (INT), Date (TEXT), Attendance (INT)
SELECT count(*) FROM exhibition WHERE YEAR >= 2005
Show theme and year for all exhibitions with ticket prices lower than 15.
artist: Artist_ID (INT), Name (TEXT), Country (TEXT), Year_Join (INT), Age (INT) exhibition: Exhibition_ID (INT), Year (INT), Theme (TEXT), Artist_ID (INT), Ticket_Price (REAL) exhibition_record: Exhibition_ID (INT), Date (TEXT), Attendance (INT)
SELECT theme , YEAR FROM exhibition WHERE ticket_price < 15
What are the theme and year for all exhibitions that have a ticket price under 15?
artist: Artist_ID (INT), Name (TEXT), Country (TEXT), Year_Join (INT), Age (INT) exhibition: Exhibition_ID (INT), Year (INT), Theme (TEXT), Artist_ID (INT), Ticket_Price (REAL) exhibition_record: Exhibition_ID (INT), Date (TEXT), Attendance (INT)
SELECT theme , YEAR FROM exhibition WHERE ticket_price < 15
Show all artist names and the number of exhibitions for each artist.
artist: Artist_ID (INT), Name (TEXT), Country (TEXT), Year_Join (INT), Age (INT) exhibition: Exhibition_ID (INT), Year (INT), Theme (TEXT), Artist_ID (INT), Ticket_Price (REAL) exhibition_record: Exhibition_ID (INT), Date (TEXT), Attendance (INT)
SELECT T2.name , count(*) FROM exhibition AS T1 JOIN artist AS T2 ON T1.artist_id = T2.artist_id GROUP BY T1.artist_id
How many exhibitions has each artist had?
artist: Artist_ID (INT), Name (TEXT), Country (TEXT), Year_Join (INT), Age (INT) exhibition: Exhibition_ID (INT), Year (INT), Theme (TEXT), Artist_ID (INT), Ticket_Price (REAL) exhibition_record: Exhibition_ID (INT), Date (TEXT), Attendance (INT)
SELECT T2.name , count(*) FROM exhibition AS T1 JOIN artist AS T2 ON T1.artist_id = T2.artist_id GROUP BY T1.artist_id
What is the name and country for the artist with most number of exhibitions?
artist: Artist_ID (INT), Name (TEXT), Country (TEXT), Year_Join (INT), Age (INT) exhibition: Exhibition_ID (INT), Year (INT), Theme (TEXT), Artist_ID (INT), Ticket_Price (REAL) exhibition_record: Exhibition_ID (INT), Date (TEXT), Attendance (INT)
SELECT T2.name , T2.country FROM exhibition AS T1 JOIN artist AS T2 ON T1.artist_id = T2.artist_id GROUP BY T1.artist_id ORDER BY count(*) DESC LIMIT 1
Return the name and country corresponding to the artist who has had the most exhibitions.
artist: Artist_ID (INT), Name (TEXT), Country (TEXT), Year_Join (INT), Age (INT) exhibition: Exhibition_ID (INT), Year (INT), Theme (TEXT), Artist_ID (INT), Ticket_Price (REAL) exhibition_record: Exhibition_ID (INT), Date (TEXT), Attendance (INT)
SELECT T2.name , T2.country FROM exhibition AS T1 JOIN artist AS T2 ON T1.artist_id = T2.artist_id GROUP BY T1.artist_id ORDER BY count(*) DESC LIMIT 1
Show names for artists without any exhibition.
artist: Artist_ID (INT), Name (TEXT), Country (TEXT), Year_Join (INT), Age (INT) exhibition: Exhibition_ID (INT), Year (INT), Theme (TEXT), Artist_ID (INT), Ticket_Price (REAL) exhibition_record: Exhibition_ID (INT), Date (TEXT), Attendance (INT)
SELECT name FROM artist WHERE artist_id NOT IN (SELECT artist_id FROM exhibition)
What are the names of artists that have not had any exhibitions?
artist: Artist_ID (INT), Name (TEXT), Country (TEXT), Year_Join (INT), Age (INT) exhibition: Exhibition_ID (INT), Year (INT), Theme (TEXT), Artist_ID (INT), Ticket_Price (REAL) exhibition_record: Exhibition_ID (INT), Date (TEXT), Attendance (INT)
SELECT name FROM artist WHERE artist_id NOT IN (SELECT artist_id FROM exhibition)
What is the theme and artist name for the exhibition with a ticket price higher than the average?
artist: Artist_ID (INT), Name (TEXT), Country (TEXT), Year_Join (INT), Age (INT) exhibition: Exhibition_ID (INT), Year (INT), Theme (TEXT), Artist_ID (INT), Ticket_Price (REAL) exhibition_record: Exhibition_ID (INT), Date (TEXT), Attendance (INT)
SELECT T1.theme , T2.name FROM exhibition AS T1 JOIN artist AS T2 ON T1.artist_id = T2.artist_id WHERE T1.ticket_price > (SELECT avg(ticket_price) FROM exhibition)
Return the names of artists and the themes of their exhibitions that had a ticket price higher than average.
artist: Artist_ID (INT), Name (TEXT), Country (TEXT), Year_Join (INT), Age (INT) exhibition: Exhibition_ID (INT), Year (INT), Theme (TEXT), Artist_ID (INT), Ticket_Price (REAL) exhibition_record: Exhibition_ID (INT), Date (TEXT), Attendance (INT)
SELECT T1.theme , T2.name FROM exhibition AS T1 JOIN artist AS T2 ON T1.artist_id = T2.artist_id WHERE T1.ticket_price > (SELECT avg(ticket_price) FROM exhibition)
Show the average, minimum, and maximum ticket prices for exhibitions for all years before 2009.
artist: Artist_ID (INT), Name (TEXT), Country (TEXT), Year_Join (INT), Age (INT) exhibition: Exhibition_ID (INT), Year (INT), Theme (TEXT), Artist_ID (INT), Ticket_Price (REAL) exhibition_record: Exhibition_ID (INT), Date (TEXT), Attendance (INT)
SELECT avg(ticket_price) , min(ticket_price) , max(ticket_price) FROM exhibition WHERE YEAR < 2009
What are the average, minimum, and maximum ticket prices for exhibitions that happened prior to 2009?
artist: Artist_ID (INT), Name (TEXT), Country (TEXT), Year_Join (INT), Age (INT) exhibition: Exhibition_ID (INT), Year (INT), Theme (TEXT), Artist_ID (INT), Ticket_Price (REAL) exhibition_record: Exhibition_ID (INT), Date (TEXT), Attendance (INT)
SELECT avg(ticket_price) , min(ticket_price) , max(ticket_price) FROM exhibition WHERE YEAR < 2009
Show theme and year for all exhibitions in an descending order of ticket price.
artist: Artist_ID (INT), Name (TEXT), Country (TEXT), Year_Join (INT), Age (INT) exhibition: Exhibition_ID (INT), Year (INT), Theme (TEXT), Artist_ID (INT), Ticket_Price (REAL) exhibition_record: Exhibition_ID (INT), Date (TEXT), Attendance (INT)
SELECT theme , YEAR FROM exhibition ORDER BY ticket_price DESC
What are the themes and years for exhibitions, sorted by ticket price descending?
artist: Artist_ID (INT), Name (TEXT), Country (TEXT), Year_Join (INT), Age (INT) exhibition: Exhibition_ID (INT), Year (INT), Theme (TEXT), Artist_ID (INT), Ticket_Price (REAL) exhibition_record: Exhibition_ID (INT), Date (TEXT), Attendance (INT)
SELECT theme , YEAR FROM exhibition ORDER BY ticket_price DESC
What is the theme, date, and attendance for the exhibition in year 2004?
artist: Artist_ID (INT), Name (TEXT), Country (TEXT), Year_Join (INT), Age (INT) exhibition: Exhibition_ID (INT), Year (INT), Theme (TEXT), Artist_ID (INT), Ticket_Price (REAL) exhibition_record: Exhibition_ID (INT), Date (TEXT), Attendance (INT)
SELECT T2.theme , T1.date , T1.attendance FROM exhibition_record AS T1 JOIN exhibition AS T2 ON T1.exhibition_id = T2.exhibition_id WHERE T2.year = 2004
Return the themes, dates, and attendance for exhibitions that happened in 2004.
artist: Artist_ID (INT), Name (TEXT), Country (TEXT), Year_Join (INT), Age (INT) exhibition: Exhibition_ID (INT), Year (INT), Theme (TEXT), Artist_ID (INT), Ticket_Price (REAL) exhibition_record: Exhibition_ID (INT), Date (TEXT), Attendance (INT)
SELECT T2.theme , T1.date , T1.attendance FROM exhibition_record AS T1 JOIN exhibition AS T2 ON T1.exhibition_id = T2.exhibition_id WHERE T2.year = 2004
Show all artist names who didn't have an exhibition in 2004.
artist: Artist_ID (INT), Name (TEXT), Country (TEXT), Year_Join (INT), Age (INT) exhibition: Exhibition_ID (INT), Year (INT), Theme (TEXT), Artist_ID (INT), Ticket_Price (REAL) exhibition_record: Exhibition_ID (INT), Date (TEXT), Attendance (INT)
SELECT name FROM artist EXCEPT SELECT T2.name FROM exhibition AS T1 JOIN artist AS T2 ON T1.artist_id = T2.artist_id WHERE T1.year = 2004
What are the names of artists who did not have an exhibition in 2004?
artist: Artist_ID (INT), Name (TEXT), Country (TEXT), Year_Join (INT), Age (INT) exhibition: Exhibition_ID (INT), Year (INT), Theme (TEXT), Artist_ID (INT), Ticket_Price (REAL) exhibition_record: Exhibition_ID (INT), Date (TEXT), Attendance (INT)
SELECT name FROM artist EXCEPT SELECT T2.name FROM exhibition AS T1 JOIN artist AS T2 ON T1.artist_id = T2.artist_id WHERE T1.year = 2004
Show the theme for exhibitions with both records of an attendance below 100 and above 500.
artist: Artist_ID (INT), Name (TEXT), Country (TEXT), Year_Join (INT), Age (INT) exhibition: Exhibition_ID (INT), Year (INT), Theme (TEXT), Artist_ID (INT), Ticket_Price (REAL) exhibition_record: Exhibition_ID (INT), Date (TEXT), Attendance (INT)
SELECT T2.theme FROM exhibition_record AS T1 JOIN exhibition AS T2 ON T1.exhibition_id = T2.exhibition_id WHERE T1.attendance < 100 INTERSECT SELECT T2.theme FROM exhibition_record AS T1 JOIN exhibition AS T2 ON T1.exhibition_id = T2.exhibition_id WHERE T1.attendance > 500
Which themes have had corresponding exhibitions that have had attendance both below 100 and above 500?
artist: Artist_ID (INT), Name (TEXT), Country (TEXT), Year_Join (INT), Age (INT) exhibition: Exhibition_ID (INT), Year (INT), Theme (TEXT), Artist_ID (INT), Ticket_Price (REAL) exhibition_record: Exhibition_ID (INT), Date (TEXT), Attendance (INT)
SELECT T2.theme FROM exhibition_record AS T1 JOIN exhibition AS T2 ON T1.exhibition_id = T2.exhibition_id WHERE T1.attendance < 100 INTERSECT SELECT T2.theme FROM exhibition_record AS T1 JOIN exhibition AS T2 ON T1.exhibition_id = T2.exhibition_id WHERE T1.attendance > 500
How many exhibitions have a attendance more than 100 or have a ticket price below 10?
artist: Artist_ID (INT), Name (TEXT), Country (TEXT), Year_Join (INT), Age (INT) exhibition: Exhibition_ID (INT), Year (INT), Theme (TEXT), Artist_ID (INT), Ticket_Price (REAL) exhibition_record: Exhibition_ID (INT), Date (TEXT), Attendance (INT)
SELECT count(*) FROM exhibition_record AS T1 JOIN exhibition AS T2 ON T1.exhibition_id = T2.exhibition_id WHERE T1.attendance > 100 OR T2.ticket_price < 10
Count the number of exhibitions that have had an attendnance of over 100 or a ticket prices under 10.
artist: Artist_ID (INT), Name (TEXT), Country (TEXT), Year_Join (INT), Age (INT) exhibition: Exhibition_ID (INT), Year (INT), Theme (TEXT), Artist_ID (INT), Ticket_Price (REAL) exhibition_record: Exhibition_ID (INT), Date (TEXT), Attendance (INT)
SELECT count(*) FROM exhibition_record AS T1 JOIN exhibition AS T2 ON T1.exhibition_id = T2.exhibition_id WHERE T1.attendance > 100 OR T2.ticket_price < 10
Show all artist names with an average exhibition attendance over 200.
artist: Artist_ID (INT), Name (TEXT), Country (TEXT), Year_Join (INT), Age (INT) exhibition: Exhibition_ID (INT), Year (INT), Theme (TEXT), Artist_ID (INT), Ticket_Price (REAL) exhibition_record: Exhibition_ID (INT), Date (TEXT), Attendance (INT)
SELECT T3.name FROM exhibition_record AS T1 JOIN exhibition AS T2 ON T1.exhibition_id = T2.exhibition_id JOIN artist AS T3 ON T3.artist_id = T2.artist_id GROUP BY T3.artist_id HAVING avg(T1.attendance) > 200
What are the names of artist whose exhibitions draw over 200 attendees on average?
artist: Artist_ID (INT), Name (TEXT), Country (TEXT), Year_Join (INT), Age (INT) exhibition: Exhibition_ID (INT), Year (INT), Theme (TEXT), Artist_ID (INT), Ticket_Price (REAL) exhibition_record: Exhibition_ID (INT), Date (TEXT), Attendance (INT)
SELECT T3.name FROM exhibition_record AS T1 JOIN exhibition AS T2 ON T1.exhibition_id = T2.exhibition_id JOIN artist AS T3 ON T3.artist_id = T2.artist_id GROUP BY T3.artist_id HAVING avg(T1.attendance) > 200
How many players are there?
player: Player_ID (INT), Sponsor_name (TEXT), Player_name (TEXT), Gender (TEXT), Residence (TEXT), Occupation (TEXT), Votes (INT), Rank (TEXT) club: Club_ID (INT), Club_name (TEXT), Region (TEXT), Start_year (INT) coach: Coach_ID (INT), Coach_name (TEXT), Gender (TEXT), Club_ID (INT), Rank (INT) player_coach: Player_ID (INT), Coach_ID (INT), Starting_year (INT) match_result: Rank (INT), Club_ID (INT), Gold (INT), Big_Silver (INT), Small_Silver (INT), Bronze (INT), Points (INT)
SELECT count(*) FROM player
List the names of players in ascending order of votes.
player: Player_ID (INT), Sponsor_name (TEXT), Player_name (TEXT), Gender (TEXT), Residence (TEXT), Occupation (TEXT), Votes (INT), Rank (TEXT) club: Club_ID (INT), Club_name (TEXT), Region (TEXT), Start_year (INT) coach: Coach_ID (INT), Coach_name (TEXT), Gender (TEXT), Club_ID (INT), Rank (INT) player_coach: Player_ID (INT), Coach_ID (INT), Starting_year (INT) match_result: Rank (INT), Club_ID (INT), Gold (INT), Big_Silver (INT), Small_Silver (INT), Bronze (INT), Points (INT)
SELECT Player_name FROM player ORDER BY Votes ASC
What are the gender and occupation of players?
player: Player_ID (INT), Sponsor_name (TEXT), Player_name (TEXT), Gender (TEXT), Residence (TEXT), Occupation (TEXT), Votes (INT), Rank (TEXT) club: Club_ID (INT), Club_name (TEXT), Region (TEXT), Start_year (INT) coach: Coach_ID (INT), Coach_name (TEXT), Gender (TEXT), Club_ID (INT), Rank (INT) player_coach: Player_ID (INT), Coach_ID (INT), Starting_year (INT) match_result: Rank (INT), Club_ID (INT), Gold (INT), Big_Silver (INT), Small_Silver (INT), Bronze (INT), Points (INT)
SELECT Gender , Occupation FROM player
List the name and residence for players whose occupation is not "Researcher".
player: Player_ID (INT), Sponsor_name (TEXT), Player_name (TEXT), Gender (TEXT), Residence (TEXT), Occupation (TEXT), Votes (INT), Rank (TEXT) club: Club_ID (INT), Club_name (TEXT), Region (TEXT), Start_year (INT) coach: Coach_ID (INT), Coach_name (TEXT), Gender (TEXT), Club_ID (INT), Rank (INT) player_coach: Player_ID (INT), Coach_ID (INT), Starting_year (INT) match_result: Rank (INT), Club_ID (INT), Gold (INT), Big_Silver (INT), Small_Silver (INT), Bronze (INT), Points (INT)
SELECT Player_name , residence FROM player WHERE Occupation != "Researcher"
Show the names of sponsors of players whose residence is either "Brandon" or "Birtle".
player: Player_ID (INT), Sponsor_name (TEXT), Player_name (TEXT), Gender (TEXT), Residence (TEXT), Occupation (TEXT), Votes (INT), Rank (TEXT) club: Club_ID (INT), Club_name (TEXT), Region (TEXT), Start_year (INT) coach: Coach_ID (INT), Coach_name (TEXT), Gender (TEXT), Club_ID (INT), Rank (INT) player_coach: Player_ID (INT), Coach_ID (INT), Starting_year (INT) match_result: Rank (INT), Club_ID (INT), Gold (INT), Big_Silver (INT), Small_Silver (INT), Bronze (INT), Points (INT)
SELECT Sponsor_name FROM player WHERE Residence = "Brandon" OR Residence = "Birtle"
What is the name of the player with the largest number of votes?
player: Player_ID (INT), Sponsor_name (TEXT), Player_name (TEXT), Gender (TEXT), Residence (TEXT), Occupation (TEXT), Votes (INT), Rank (TEXT) club: Club_ID (INT), Club_name (TEXT), Region (TEXT), Start_year (INT) coach: Coach_ID (INT), Coach_name (TEXT), Gender (TEXT), Club_ID (INT), Rank (INT) player_coach: Player_ID (INT), Coach_ID (INT), Starting_year (INT) match_result: Rank (INT), Club_ID (INT), Gold (INT), Big_Silver (INT), Small_Silver (INT), Bronze (INT), Points (INT)
SELECT Player_name FROM player ORDER BY Votes DESC LIMIT 1
Show different occupations along with the number of players in each occupation.
player: Player_ID (INT), Sponsor_name (TEXT), Player_name (TEXT), Gender (TEXT), Residence (TEXT), Occupation (TEXT), Votes (INT), Rank (TEXT) club: Club_ID (INT), Club_name (TEXT), Region (TEXT), Start_year (INT) coach: Coach_ID (INT), Coach_name (TEXT), Gender (TEXT), Club_ID (INT), Rank (INT) player_coach: Player_ID (INT), Coach_ID (INT), Starting_year (INT) match_result: Rank (INT), Club_ID (INT), Gold (INT), Big_Silver (INT), Small_Silver (INT), Bronze (INT), Points (INT)
SELECT Occupation , COUNT(*) FROM player GROUP BY Occupation
Please show the most common occupation of players.
player: Player_ID (INT), Sponsor_name (TEXT), Player_name (TEXT), Gender (TEXT), Residence (TEXT), Occupation (TEXT), Votes (INT), Rank (TEXT) club: Club_ID (INT), Club_name (TEXT), Region (TEXT), Start_year (INT) coach: Coach_ID (INT), Coach_name (TEXT), Gender (TEXT), Club_ID (INT), Rank (INT) player_coach: Player_ID (INT), Coach_ID (INT), Starting_year (INT) match_result: Rank (INT), Club_ID (INT), Gold (INT), Big_Silver (INT), Small_Silver (INT), Bronze (INT), Points (INT)
SELECT Occupation FROM player GROUP BY Occupation ORDER BY COUNT(*) DESC LIMIT 1
Show the residences that have at least two players.
player: Player_ID (INT), Sponsor_name (TEXT), Player_name (TEXT), Gender (TEXT), Residence (TEXT), Occupation (TEXT), Votes (INT), Rank (TEXT) club: Club_ID (INT), Club_name (TEXT), Region (TEXT), Start_year (INT) coach: Coach_ID (INT), Coach_name (TEXT), Gender (TEXT), Club_ID (INT), Rank (INT) player_coach: Player_ID (INT), Coach_ID (INT), Starting_year (INT) match_result: Rank (INT), Club_ID (INT), Gold (INT), Big_Silver (INT), Small_Silver (INT), Bronze (INT), Points (INT)
SELECT Residence FROM player GROUP BY Residence HAVING COUNT(*) >= 2
Show the names of players and names of their coaches.
player: Player_ID (INT), Sponsor_name (TEXT), Player_name (TEXT), Gender (TEXT), Residence (TEXT), Occupation (TEXT), Votes (INT), Rank (TEXT) club: Club_ID (INT), Club_name (TEXT), Region (TEXT), Start_year (INT) coach: Coach_ID (INT), Coach_name (TEXT), Gender (TEXT), Club_ID (INT), Rank (INT) player_coach: Player_ID (INT), Coach_ID (INT), Starting_year (INT) match_result: Rank (INT), Club_ID (INT), Gold (INT), Big_Silver (INT), Small_Silver (INT), Bronze (INT), Points (INT)
SELECT T3.Player_name , T2.coach_name FROM player_coach AS T1 JOIN coach AS T2 ON T1.Coach_ID = T2.Coach_ID JOIN player AS T3 ON T1.Player_ID = T3.Player_ID
Show the names of players coached by the rank 1 coach.
player: Player_ID (INT), Sponsor_name (TEXT), Player_name (TEXT), Gender (TEXT), Residence (TEXT), Occupation (TEXT), Votes (INT), Rank (TEXT) club: Club_ID (INT), Club_name (TEXT), Region (TEXT), Start_year (INT) coach: Coach_ID (INT), Coach_name (TEXT), Gender (TEXT), Club_ID (INT), Rank (INT) player_coach: Player_ID (INT), Coach_ID (INT), Starting_year (INT) match_result: Rank (INT), Club_ID (INT), Gold (INT), Big_Silver (INT), Small_Silver (INT), Bronze (INT), Points (INT)
SELECT T3.Player_name FROM player_coach AS T1 JOIN coach AS T2 ON T1.Coach_ID = T2.Coach_ID JOIN player AS T3 ON T1.Player_ID = T3.Player_ID WHERE T2.Rank = 1
Show the names and genders of players with a coach starting after 2011.
player: Player_ID (INT), Sponsor_name (TEXT), Player_name (TEXT), Gender (TEXT), Residence (TEXT), Occupation (TEXT), Votes (INT), Rank (TEXT) club: Club_ID (INT), Club_name (TEXT), Region (TEXT), Start_year (INT) coach: Coach_ID (INT), Coach_name (TEXT), Gender (TEXT), Club_ID (INT), Rank (INT) player_coach: Player_ID (INT), Coach_ID (INT), Starting_year (INT) match_result: Rank (INT), Club_ID (INT), Gold (INT), Big_Silver (INT), Small_Silver (INT), Bronze (INT), Points (INT)
SELECT T3.Player_name , T3.gender FROM player_coach AS T1 JOIN coach AS T2 ON T1.Coach_ID = T2.Coach_ID JOIN player AS T3 ON T1.Player_ID = T3.Player_ID WHERE T1.Starting_year > 2011
Show the names of players and names of their coaches in descending order of the votes of players.
player: Player_ID (INT), Sponsor_name (TEXT), Player_name (TEXT), Gender (TEXT), Residence (TEXT), Occupation (TEXT), Votes (INT), Rank (TEXT) club: Club_ID (INT), Club_name (TEXT), Region (TEXT), Start_year (INT) coach: Coach_ID (INT), Coach_name (TEXT), Gender (TEXT), Club_ID (INT), Rank (INT) player_coach: Player_ID (INT), Coach_ID (INT), Starting_year (INT) match_result: Rank (INT), Club_ID (INT), Gold (INT), Big_Silver (INT), Small_Silver (INT), Bronze (INT), Points (INT)
SELECT T3.Player_name , T2.coach_name FROM player_coach AS T1 JOIN coach AS T2 ON T1.Coach_ID = T2.Coach_ID JOIN player AS T3 ON T1.Player_ID = T3.Player_ID ORDER BY T3.Votes DESC
List the names of players that do not have coaches.
player: Player_ID (INT), Sponsor_name (TEXT), Player_name (TEXT), Gender (TEXT), Residence (TEXT), Occupation (TEXT), Votes (INT), Rank (TEXT) club: Club_ID (INT), Club_name (TEXT), Region (TEXT), Start_year (INT) coach: Coach_ID (INT), Coach_name (TEXT), Gender (TEXT), Club_ID (INT), Rank (INT) player_coach: Player_ID (INT), Coach_ID (INT), Starting_year (INT) match_result: Rank (INT), Club_ID (INT), Gold (INT), Big_Silver (INT), Small_Silver (INT), Bronze (INT), Points (INT)
SELECT Player_name FROM player WHERE Player_ID NOT IN (SELECT Player_ID FROM player_coach)
Show the residences that have both a player of gender "M" and a player of gender "F".
player: Player_ID (INT), Sponsor_name (TEXT), Player_name (TEXT), Gender (TEXT), Residence (TEXT), Occupation (TEXT), Votes (INT), Rank (TEXT) club: Club_ID (INT), Club_name (TEXT), Region (TEXT), Start_year (INT) coach: Coach_ID (INT), Coach_name (TEXT), Gender (TEXT), Club_ID (INT), Rank (INT) player_coach: Player_ID (INT), Coach_ID (INT), Starting_year (INT) match_result: Rank (INT), Club_ID (INT), Gold (INT), Big_Silver (INT), Small_Silver (INT), Bronze (INT), Points (INT)
SELECT Residence FROM player WHERE gender = "M" INTERSECT SELECT Residence FROM player WHERE gender = "F"
How many coaches does each club has? List the club id, name and the number of coaches.
player: Player_ID (INT), Sponsor_name (TEXT), Player_name (TEXT), Gender (TEXT), Residence (TEXT), Occupation (TEXT), Votes (INT), Rank (TEXT) club: Club_ID (INT), Club_name (TEXT), Region (TEXT), Start_year (INT) coach: Coach_ID (INT), Coach_name (TEXT), Gender (TEXT), Club_ID (INT), Rank (INT) player_coach: Player_ID (INT), Coach_ID (INT), Starting_year (INT) match_result: Rank (INT), Club_ID (INT), Gold (INT), Big_Silver (INT), Small_Silver (INT), Bronze (INT), Points (INT)
SELECT T1.club_id , T1.club_name, count(*) FROM club AS T1 JOIN coach AS T2 ON T1.club_id = T2.club_id GROUP BY T1.club_id
How many gold medals has the club with the most coaches won?
player: Player_ID (INT), Sponsor_name (TEXT), Player_name (TEXT), Gender (TEXT), Residence (TEXT), Occupation (TEXT), Votes (INT), Rank (TEXT) club: Club_ID (INT), Club_name (TEXT), Region (TEXT), Start_year (INT) coach: Coach_ID (INT), Coach_name (TEXT), Gender (TEXT), Club_ID (INT), Rank (INT) player_coach: Player_ID (INT), Coach_ID (INT), Starting_year (INT) match_result: Rank (INT), Club_ID (INT), Gold (INT), Big_Silver (INT), Small_Silver (INT), Bronze (INT), Points (INT)
SELECT T1.club_id , T1.gold FROM match_result AS T1 JOIN coach AS T2 ON T1.club_id = T2.club_id GROUP BY T1.club_id ORDER BY count(*) DESC LIMIT 1
How many gymnasts are there?
gymnast: Gymnast_ID (INT), Floor_Exercise_Points (REAL), Pommel_Horse_Points (REAL), Rings_Points (REAL), Vault_Points (REAL), Parallel_Bars_Points (REAL), Horizontal_Bar_Points (REAL), Total_Points (REAL) people: People_ID (INT), Name (TEXT), Age (REAL), Height (REAL), Hometown (TEXT)
SELECT count(*) FROM gymnast
Count the number of gymnasts.
gymnast: Gymnast_ID (INT), Floor_Exercise_Points (REAL), Pommel_Horse_Points (REAL), Rings_Points (REAL), Vault_Points (REAL), Parallel_Bars_Points (REAL), Horizontal_Bar_Points (REAL), Total_Points (REAL) people: People_ID (INT), Name (TEXT), Age (REAL), Height (REAL), Hometown (TEXT)
SELECT count(*) FROM gymnast
List the total points of gymnasts in descending order.
gymnast: Gymnast_ID (INT), Floor_Exercise_Points (REAL), Pommel_Horse_Points (REAL), Rings_Points (REAL), Vault_Points (REAL), Parallel_Bars_Points (REAL), Horizontal_Bar_Points (REAL), Total_Points (REAL) people: People_ID (INT), Name (TEXT), Age (REAL), Height (REAL), Hometown (TEXT)
SELECT Total_Points FROM gymnast ORDER BY Total_Points DESC
What are the total points for all gymnasts, ordered by total points descending?
gymnast: Gymnast_ID (INT), Floor_Exercise_Points (REAL), Pommel_Horse_Points (REAL), Rings_Points (REAL), Vault_Points (REAL), Parallel_Bars_Points (REAL), Horizontal_Bar_Points (REAL), Total_Points (REAL) people: People_ID (INT), Name (TEXT), Age (REAL), Height (REAL), Hometown (TEXT)
SELECT Total_Points FROM gymnast ORDER BY Total_Points DESC
List the total points of gymnasts in descending order of floor exercise points.
gymnast: Gymnast_ID (INT), Floor_Exercise_Points (REAL), Pommel_Horse_Points (REAL), Rings_Points (REAL), Vault_Points (REAL), Parallel_Bars_Points (REAL), Horizontal_Bar_Points (REAL), Total_Points (REAL) people: People_ID (INT), Name (TEXT), Age (REAL), Height (REAL), Hometown (TEXT)
SELECT Total_Points FROM gymnast ORDER BY Floor_Exercise_Points DESC