db_name
stringclasses 146
values | prompt
stringlengths 310
4.81k
|
---|---|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# How many transactions correspond to each invoice number?
#
### SQL:
#
# SELECT invoice_number , count(*) FROM Financial_transactions GROUP BY invoice_number
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# What is the invoice number and invoice date for the invoice with most number of transactions?
#
### SQL:
#
# SELECT T2.invoice_number , T2.invoice_date FROM Financial_transactions AS T1 JOIN Invoices AS T2 ON T1.invoice_number = T2.invoice_number GROUP BY T1.invoice_number ORDER BY count(*) DESC LIMIT 1
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# What is the invoice number and invoice date corresponding to the invoice with the greatest number of transactions?
#
### SQL:
#
# SELECT T2.invoice_number , T2.invoice_date FROM Financial_transactions AS T1 JOIN Invoices AS T2 ON T1.invoice_number = T2.invoice_number GROUP BY T1.invoice_number ORDER BY count(*) DESC LIMIT 1
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# How many invoices do we have?
#
### SQL:
#
# SELECT count(*) FROM Invoices
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# Count the number of invoices.
#
### SQL:
#
# SELECT count(*) FROM Invoices
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# Show invoice dates and order id and details for all invoices.
#
### SQL:
#
# SELECT T1.invoice_date , T1.order_id , T2.order_details FROM Invoices AS T1 JOIN Orders AS T2 ON T1.order_id = T2.order_id
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# What are the invoice dates, order ids, and order details for all invoices?
#
### SQL:
#
# SELECT T1.invoice_date , T1.order_id , T2.order_details FROM Invoices AS T1 JOIN Orders AS T2 ON T1.order_id = T2.order_id
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# Show the order ids and the number of invoices for each order.
#
### SQL:
#
# SELECT order_id , count(*) FROM Invoices GROUP BY order_id
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# How many invoices correspond to each order id?
#
### SQL:
#
# SELECT order_id , count(*) FROM Invoices GROUP BY order_id
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# What is the order id and order details for the order more than two invoices.
#
### SQL:
#
# SELECT T2.order_id , T2.order_details FROM Invoices AS T1 JOIN Orders AS T2 ON T1.order_id = T2.order_id GROUP BY T2.order_id HAVING count(*) > 2
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# Return the order ids and details for orderes with two or more invoices.
#
### SQL:
#
# SELECT T2.order_id , T2.order_details FROM Invoices AS T1 JOIN Orders AS T2 ON T1.order_id = T2.order_id GROUP BY T2.order_id HAVING count(*) > 2
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# What is the customer last name, id and phone number with most number of orders?
#
### SQL:
#
# 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
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# Return the last name, id and phone number of the customer who has made the greatest number of orders.
#
### SQL:
#
# 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
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# Show all product names without an order.
#
### SQL:
#
# 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
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# What are the names of products that have never been ordered?
#
### SQL:
#
# 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
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# Show all product names and the total quantity ordered for each product name.
#
### SQL:
#
# 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
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# What are the different product names, and what is the sum of quantity ordered for each product?
#
### SQL:
#
# 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
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# Show the order ids and the number of items in each order.
#
### SQL:
#
# SELECT order_id , count(*) FROM Order_items GROUP BY order_id
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# How many order items correspond to each order id?
#
### SQL:
#
# SELECT order_id , count(*) FROM Order_items GROUP BY order_id
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# Show the product ids and the number of unique orders containing each product.
#
### SQL:
#
# SELECT product_id , count(DISTINCT order_id) FROM Order_items GROUP BY product_id
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# How many distinct order ids correspond to each product?
#
### SQL:
#
# SELECT product_id , count(DISTINCT order_id) FROM Order_items GROUP BY product_id
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# Show all product names and the number of customers having an order on each product.
#
### SQL:
#
# 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
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# What are teh names of the different products, as well as the number of customers who have ordered each product.
#
### SQL:
#
# 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
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# Show order ids and the number of products in each order.
#
### SQL:
#
# SELECT order_id , count(DISTINCT product_id) FROM Order_items GROUP BY order_id
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# How many different products correspond to each order id?
#
### SQL:
#
# SELECT order_id , count(DISTINCT product_id) FROM Order_items GROUP BY order_id
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# Show order ids and the total quantity in each order.
#
### SQL:
#
# SELECT order_id , sum(product_quantity) FROM Order_items GROUP BY order_id
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# Give the order ids for all orders, as well as the total product quantity in each.
#
### SQL:
#
# SELECT order_id , sum(product_quantity) FROM Order_items GROUP BY order_id
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# How many products were not included in any order?
#
### SQL:
#
# SELECT count(*) FROM products WHERE product_id NOT IN ( SELECT product_id FROM Order_items )
#
### End.
|
customers_and_invoices
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Customers ( customer_id, customer_first_name, customer_middle_initial, customer_last_name, gender, email_address, login_name, login_password, phone_number, town_city, state_county_province, country )
# Orders ( order_id, customer_id, date_order_placed, order_details )
# Invoices ( invoice_number, order_id, invoice_date )
# Accounts ( account_id, customer_id, date_account_opened, account_name, other_account_details )
# Product_Categories ( production_type_code, product_type_description, vat_rating )
# Products ( product_id, parent_product_id, production_type_code, unit_price, product_name, product_color, product_size )
# Financial_Transactions ( transaction_id, account_id, invoice_number, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details )
# Order_Items ( order_item_id, order_id, product_id, product_quantity, other_order_item_details )
# Invoice_Line_Items ( order_item_id, invoice_number, product_id, product_title, product_quantity, product_price, derived_product_cost, derived_vat_payable, derived_total_cost )
#
# Orders.customer_id can be joined with Customers.customer_id
# Invoices.order_id can be joined with Orders.order_id
# Accounts.customer_id can be joined with Customers.customer_id
# Products.production_type_code can be joined with Product_Categories.production_type_code
# Financial_Transactions.account_id can be joined with Accounts.account_id
# Financial_Transactions.invoice_number can be joined with Invoices.invoice_number
# Order_Items.order_id can be joined with Orders.order_id
# Order_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.product_id can be joined with Products.product_id
# Invoice_Line_Items.invoice_number can be joined with Invoices.invoice_number
# Invoice_Line_Items.order_item_id can be joined with Order_Items.order_item_id
#
### Question:
#
# Count the number of products that were never ordered.
#
### SQL:
#
# SELECT count(*) FROM products WHERE product_id NOT IN ( SELECT product_id FROM Order_items )
#
### End.
|
wedding
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# people ( People_ID, Name, Country, Is_Male, Age )
# church ( Church_ID, Name, Organized_by, Open_Date, Continuation_of )
# wedding ( Church_ID, Male_ID, Female_ID, Year )
#
# wedding.Female_ID can be joined with people.People_ID
# wedding.Male_ID can be joined with people.People_ID
# wedding.Church_ID can be joined with church.Church_ID
#
### Question:
#
# How many churches opened before 1850 are there?
#
### SQL:
#
# SELECT count(*) FROM Church WHERE Open_Date < 1850
#
### End.
|
wedding
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# people ( People_ID, Name, Country, Is_Male, Age )
# church ( Church_ID, Name, Organized_by, Open_Date, Continuation_of )
# wedding ( Church_ID, Male_ID, Female_ID, Year )
#
# wedding.Female_ID can be joined with people.People_ID
# wedding.Male_ID can be joined with people.People_ID
# wedding.Church_ID can be joined with church.Church_ID
#
### Question:
#
# Show the name, open date, and organizer for all churches.
#
### SQL:
#
# SELECT name , open_date , organized_by FROM Church
#
### End.
|
wedding
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# people ( People_ID, Name, Country, Is_Male, Age )
# church ( Church_ID, Name, Organized_by, Open_Date, Continuation_of )
# wedding ( Church_ID, Male_ID, Female_ID, Year )
#
# wedding.Female_ID can be joined with people.People_ID
# wedding.Male_ID can be joined with people.People_ID
# wedding.Church_ID can be joined with church.Church_ID
#
### Question:
#
# List all church names in descending order of opening date.
#
### SQL:
#
# SELECT name FROM church ORDER BY open_date DESC
#
### End.
|
wedding
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# people ( People_ID, Name, Country, Is_Male, Age )
# church ( Church_ID, Name, Organized_by, Open_Date, Continuation_of )
# wedding ( Church_ID, Male_ID, Female_ID, Year )
#
# wedding.Female_ID can be joined with people.People_ID
# wedding.Male_ID can be joined with people.People_ID
# wedding.Church_ID can be joined with church.Church_ID
#
### Question:
#
# Show the opening year in whcih at least two churches opened.
#
### SQL:
#
# SELECT open_date FROM church GROUP BY open_date HAVING count(*) >= 2
#
### End.
|
wedding
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# people ( People_ID, Name, Country, Is_Male, Age )
# church ( Church_ID, Name, Organized_by, Open_Date, Continuation_of )
# wedding ( Church_ID, Male_ID, Female_ID, Year )
#
# wedding.Female_ID can be joined with people.People_ID
# wedding.Male_ID can be joined with people.People_ID
# wedding.Church_ID can be joined with church.Church_ID
#
### Question:
#
# Show the organizer and name for churches that opened between 1830 and 1840.
#
### SQL:
#
# SELECT organized_by , name FROM church WHERE open_date BETWEEN 1830 AND 1840
#
### End.
|
wedding
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# people ( People_ID, Name, Country, Is_Male, Age )
# church ( Church_ID, Name, Organized_by, Open_Date, Continuation_of )
# wedding ( Church_ID, Male_ID, Female_ID, Year )
#
# wedding.Female_ID can be joined with people.People_ID
# wedding.Male_ID can be joined with people.People_ID
# wedding.Church_ID can be joined with church.Church_ID
#
### Question:
#
# Show all opening years and the number of churches that opened in that year.
#
### SQL:
#
# SELECT open_date , count(*) FROM church GROUP BY open_date
#
### End.
|
wedding
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# people ( People_ID, Name, Country, Is_Male, Age )
# church ( Church_ID, Name, Organized_by, Open_Date, Continuation_of )
# wedding ( Church_ID, Male_ID, Female_ID, Year )
#
# wedding.Female_ID can be joined with people.People_ID
# wedding.Male_ID can be joined with people.People_ID
# wedding.Church_ID can be joined with church.Church_ID
#
### Question:
#
# Show the name and opening year for three churches that opened most recently.
#
### SQL:
#
# SELECT name , open_date FROM church ORDER BY open_date DESC LIMIT 3
#
### End.
|
wedding
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# people ( People_ID, Name, Country, Is_Male, Age )
# church ( Church_ID, Name, Organized_by, Open_Date, Continuation_of )
# wedding ( Church_ID, Male_ID, Female_ID, Year )
#
# wedding.Female_ID can be joined with people.People_ID
# wedding.Male_ID can be joined with people.People_ID
# wedding.Church_ID can be joined with church.Church_ID
#
### Question:
#
# How many female people are older than 30 in our record?
#
### SQL:
#
# SELECT count(*) FROM people WHERE is_male = 'F' AND age > 30
#
### End.
|
wedding
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# people ( People_ID, Name, Country, Is_Male, Age )
# church ( Church_ID, Name, Organized_by, Open_Date, Continuation_of )
# wedding ( Church_ID, Male_ID, Female_ID, Year )
#
# wedding.Female_ID can be joined with people.People_ID
# wedding.Male_ID can be joined with people.People_ID
# wedding.Church_ID can be joined with church.Church_ID
#
### Question:
#
# Show the country where people older than 30 and younger than 25 are from.
#
### SQL:
#
# SELECT country FROM people WHERE age < 25 INTERSECT SELECT country FROM people WHERE age > 30
#
### End.
|
wedding
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# people ( People_ID, Name, Country, Is_Male, Age )
# church ( Church_ID, Name, Organized_by, Open_Date, Continuation_of )
# wedding ( Church_ID, Male_ID, Female_ID, Year )
#
# wedding.Female_ID can be joined with people.People_ID
# wedding.Male_ID can be joined with people.People_ID
# wedding.Church_ID can be joined with church.Church_ID
#
### Question:
#
# Show the minimum, maximum, and average age for all people.
#
### SQL:
#
# SELECT min(age) , max(age) , avg(age) FROM people
#
### End.
|
wedding
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# people ( People_ID, Name, Country, Is_Male, Age )
# church ( Church_ID, Name, Organized_by, Open_Date, Continuation_of )
# wedding ( Church_ID, Male_ID, Female_ID, Year )
#
# wedding.Female_ID can be joined with people.People_ID
# wedding.Male_ID can be joined with people.People_ID
# wedding.Church_ID can be joined with church.Church_ID
#
### Question:
#
# Show the name and country for all people whose age is smaller than the average.
#
### SQL:
#
# SELECT name , country FROM people WHERE age < (SELECT avg(age) FROM people)
#
### End.
|
wedding
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# people ( People_ID, Name, Country, Is_Male, Age )
# church ( Church_ID, Name, Organized_by, Open_Date, Continuation_of )
# wedding ( Church_ID, Male_ID, Female_ID, Year )
#
# wedding.Female_ID can be joined with people.People_ID
# wedding.Male_ID can be joined with people.People_ID
# wedding.Church_ID can be joined with church.Church_ID
#
### Question:
#
# Show the pair of male and female names in all weddings after year 2014
#
### SQL:
#
# 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
#
### End.
|
wedding
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# people ( People_ID, Name, Country, Is_Male, Age )
# church ( Church_ID, Name, Organized_by, Open_Date, Continuation_of )
# wedding ( Church_ID, Male_ID, Female_ID, Year )
#
# wedding.Female_ID can be joined with people.People_ID
# wedding.Male_ID can be joined with people.People_ID
# wedding.Church_ID can be joined with church.Church_ID
#
### Question:
#
# Show the name and age for all male people who don't have a wedding.
#
### SQL:
#
# SELECT name , age FROM people WHERE is_male = 'T' AND people_id NOT IN (SELECT male_id FROM wedding)
#
### End.
|
wedding
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# people ( People_ID, Name, Country, Is_Male, Age )
# church ( Church_ID, Name, Organized_by, Open_Date, Continuation_of )
# wedding ( Church_ID, Male_ID, Female_ID, Year )
#
# wedding.Female_ID can be joined with people.People_ID
# wedding.Male_ID can be joined with people.People_ID
# wedding.Church_ID can be joined with church.Church_ID
#
### Question:
#
# Show all church names except for those that had a wedding in year 2015.
#
### SQL:
#
# 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
#
### End.
|
wedding
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# people ( People_ID, Name, Country, Is_Male, Age )
# church ( Church_ID, Name, Organized_by, Open_Date, Continuation_of )
# wedding ( Church_ID, Male_ID, Female_ID, Year )
#
# wedding.Female_ID can be joined with people.People_ID
# wedding.Male_ID can be joined with people.People_ID
# wedding.Church_ID can be joined with church.Church_ID
#
### Question:
#
# Show all church names that have hosted least two weddings.
#
### SQL:
#
# 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
#
### End.
|
wedding
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# people ( People_ID, Name, Country, Is_Male, Age )
# church ( Church_ID, Name, Organized_by, Open_Date, Continuation_of )
# wedding ( Church_ID, Male_ID, Female_ID, Year )
#
# wedding.Female_ID can be joined with people.People_ID
# wedding.Male_ID can be joined with people.People_ID
# wedding.Church_ID can be joined with church.Church_ID
#
### Question:
#
# Show the names for all females from Canada having a wedding in year 2016.
#
### SQL:
#
# 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'
#
### End.
|
wedding
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# people ( People_ID, Name, Country, Is_Male, Age )
# church ( Church_ID, Name, Organized_by, Open_Date, Continuation_of )
# wedding ( Church_ID, Male_ID, Female_ID, Year )
#
# wedding.Female_ID can be joined with people.People_ID
# wedding.Male_ID can be joined with people.People_ID
# wedding.Church_ID can be joined with church.Church_ID
#
### Question:
#
# How many weddings are there in year 2016?
#
### SQL:
#
# SELECT count(*) FROM wedding WHERE YEAR = 2016
#
### End.
|
wedding
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# people ( People_ID, Name, Country, Is_Male, Age )
# church ( Church_ID, Name, Organized_by, Open_Date, Continuation_of )
# wedding ( Church_ID, Male_ID, Female_ID, Year )
#
# wedding.Female_ID can be joined with people.People_ID
# wedding.Male_ID can be joined with people.People_ID
# wedding.Church_ID can be joined with church.Church_ID
#
### Question:
#
# Show the church names for the weddings of all people older than 30.
#
### SQL:
#
# 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
#
### End.
|
wedding
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# people ( People_ID, Name, Country, Is_Male, Age )
# church ( Church_ID, Name, Organized_by, Open_Date, Continuation_of )
# wedding ( Church_ID, Male_ID, Female_ID, Year )
#
# wedding.Female_ID can be joined with people.People_ID
# wedding.Male_ID can be joined with people.People_ID
# wedding.Church_ID can be joined with church.Church_ID
#
### Question:
#
# Show all countries and the number of people from each country.
#
### SQL:
#
# SELECT country , count(*) FROM people GROUP BY country
#
### End.
|
wedding
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# people ( People_ID, Name, Country, Is_Male, Age )
# church ( Church_ID, Name, Organized_by, Open_Date, Continuation_of )
# wedding ( Church_ID, Male_ID, Female_ID, Year )
#
# wedding.Female_ID can be joined with people.People_ID
# wedding.Male_ID can be joined with people.People_ID
# wedding.Church_ID can be joined with church.Church_ID
#
### Question:
#
# How many churches have a wedding in year 2016?
#
### SQL:
#
# SELECT COUNT (DISTINCT church_id) FROM wedding WHERE YEAR = 2016
#
### End.
|
theme_gallery
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# artist ( Artist_ID, Name, Country, Year_Join, Age )
# exhibition ( Exhibition_ID, Year, Theme, Artist_ID, Ticket_Price )
# exhibition_record ( Exhibition_ID, Date, Attendance )
#
# exhibition.Artist_ID can be joined with artist.Artist_ID
# exhibition_record.Exhibition_ID can be joined with exhibition.Exhibition_ID
#
### Question:
#
# How many artists do we have?
#
### SQL:
#
# SELECT count(*) FROM artist
#
### End.
|
theme_gallery
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# artist ( Artist_ID, Name, Country, Year_Join, Age )
# exhibition ( Exhibition_ID, Year, Theme, Artist_ID, Ticket_Price )
# exhibition_record ( Exhibition_ID, Date, Attendance )
#
# exhibition.Artist_ID can be joined with artist.Artist_ID
# exhibition_record.Exhibition_ID can be joined with exhibition.Exhibition_ID
#
### Question:
#
# Count the number of artists.
#
### SQL:
#
# SELECT count(*) FROM artist
#
### End.
|
theme_gallery
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# artist ( Artist_ID, Name, Country, Year_Join, Age )
# exhibition ( Exhibition_ID, Year, Theme, Artist_ID, Ticket_Price )
# exhibition_record ( Exhibition_ID, Date, Attendance )
#
# exhibition.Artist_ID can be joined with artist.Artist_ID
# exhibition_record.Exhibition_ID can be joined with exhibition.Exhibition_ID
#
### Question:
#
# Show all artist name, age, and country ordered by the yeared they joined.
#
### SQL:
#
# SELECT name , age , country FROM artist ORDER BY Year_Join
#
### End.
|
theme_gallery
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# artist ( Artist_ID, Name, Country, Year_Join, Age )
# exhibition ( Exhibition_ID, Year, Theme, Artist_ID, Ticket_Price )
# exhibition_record ( Exhibition_ID, Date, Attendance )
#
# exhibition.Artist_ID can be joined with artist.Artist_ID
# exhibition_record.Exhibition_ID can be joined with exhibition.Exhibition_ID
#
### Question:
#
# What are the names, ages, and countries of artists, sorted by the year they joined?
#
### SQL:
#
# SELECT name , age , country FROM artist ORDER BY Year_Join
#
### End.
|
theme_gallery
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# artist ( Artist_ID, Name, Country, Year_Join, Age )
# exhibition ( Exhibition_ID, Year, Theme, Artist_ID, Ticket_Price )
# exhibition_record ( Exhibition_ID, Date, Attendance )
#
# exhibition.Artist_ID can be joined with artist.Artist_ID
# exhibition_record.Exhibition_ID can be joined with exhibition.Exhibition_ID
#
### Question:
#
# What are all distinct country for artists?
#
### SQL:
#
# SELECT DISTINCT country FROM artist
#
### End.
|
theme_gallery
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# artist ( Artist_ID, Name, Country, Year_Join, Age )
# exhibition ( Exhibition_ID, Year, Theme, Artist_ID, Ticket_Price )
# exhibition_record ( Exhibition_ID, Date, Attendance )
#
# exhibition.Artist_ID can be joined with artist.Artist_ID
# exhibition_record.Exhibition_ID can be joined with exhibition.Exhibition_ID
#
### Question:
#
# Return the different countries for artists.
#
### SQL:
#
# SELECT DISTINCT country FROM artist
#
### End.
|
theme_gallery
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# artist ( Artist_ID, Name, Country, Year_Join, Age )
# exhibition ( Exhibition_ID, Year, Theme, Artist_ID, Ticket_Price )
# exhibition_record ( Exhibition_ID, Date, Attendance )
#
# exhibition.Artist_ID can be joined with artist.Artist_ID
# exhibition_record.Exhibition_ID can be joined with exhibition.Exhibition_ID
#
### Question:
#
# Show all artist names and the year joined who are not from United States.
#
### SQL:
#
# SELECT name , year_join FROM artist WHERE country != 'United States'
#
### End.
|
theme_gallery
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# artist ( Artist_ID, Name, Country, Year_Join, Age )
# exhibition ( Exhibition_ID, Year, Theme, Artist_ID, Ticket_Price )
# exhibition_record ( Exhibition_ID, Date, Attendance )
#
# exhibition.Artist_ID can be joined with artist.Artist_ID
# exhibition_record.Exhibition_ID can be joined with exhibition.Exhibition_ID
#
### Question:
#
# What are the names and year of joining for artists that do not have the country "United States"?
#
### SQL:
#
# SELECT name , year_join FROM artist WHERE country != 'United States'
#
### End.
|
theme_gallery
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# artist ( Artist_ID, Name, Country, Year_Join, Age )
# exhibition ( Exhibition_ID, Year, Theme, Artist_ID, Ticket_Price )
# exhibition_record ( Exhibition_ID, Date, Attendance )
#
# exhibition.Artist_ID can be joined with artist.Artist_ID
# exhibition_record.Exhibition_ID can be joined with exhibition.Exhibition_ID
#
### Question:
#
# How many artists are above age 46 and joined after 1990?
#
### SQL:
#
# SELECT count(*) FROM artist WHERE age > 46 AND year_join > 1990
#
### End.
|
theme_gallery
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# artist ( Artist_ID, Name, Country, Year_Join, Age )
# exhibition ( Exhibition_ID, Year, Theme, Artist_ID, Ticket_Price )
# exhibition_record ( Exhibition_ID, Date, Attendance )
#
# exhibition.Artist_ID can be joined with artist.Artist_ID
# exhibition_record.Exhibition_ID can be joined with exhibition.Exhibition_ID
#
### Question:
#
# Count the number of artists who are older than 46 and joined after 1990.
#
### SQL:
#
# SELECT count(*) FROM artist WHERE age > 46 AND year_join > 1990
#
### End.
|
theme_gallery
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# artist ( Artist_ID, Name, Country, Year_Join, Age )
# exhibition ( Exhibition_ID, Year, Theme, Artist_ID, Ticket_Price )
# exhibition_record ( Exhibition_ID, Date, Attendance )
#
# exhibition.Artist_ID can be joined with artist.Artist_ID
# exhibition_record.Exhibition_ID can be joined with exhibition.Exhibition_ID
#
### Question:
#
# What is the average and minimum age of all artists from United States.
#
### SQL:
#
# SELECT avg(age) , min(age) FROM artist WHERE country = 'United States'
#
### End.
|
theme_gallery
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# artist ( Artist_ID, Name, Country, Year_Join, Age )
# exhibition ( Exhibition_ID, Year, Theme, Artist_ID, Ticket_Price )
# exhibition_record ( Exhibition_ID, Date, Attendance )
#
# exhibition.Artist_ID can be joined with artist.Artist_ID
# exhibition_record.Exhibition_ID can be joined with exhibition.Exhibition_ID
#
### Question:
#
# Return the average and minimum ages across artists from the United States.
#
### SQL:
#
# SELECT avg(age) , min(age) FROM artist WHERE country = 'United States'
#
### End.
|
theme_gallery
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# artist ( Artist_ID, Name, Country, Year_Join, Age )
# exhibition ( Exhibition_ID, Year, Theme, Artist_ID, Ticket_Price )
# exhibition_record ( Exhibition_ID, Date, Attendance )
#
# exhibition.Artist_ID can be joined with artist.Artist_ID
# exhibition_record.Exhibition_ID can be joined with exhibition.Exhibition_ID
#
### Question:
#
# What is the name of the artist who joined latest?
#
### SQL:
#
# SELECT name FROM artist ORDER BY year_join DESC LIMIT 1
#
### End.
|
theme_gallery
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# artist ( Artist_ID, Name, Country, Year_Join, Age )
# exhibition ( Exhibition_ID, Year, Theme, Artist_ID, Ticket_Price )
# exhibition_record ( Exhibition_ID, Date, Attendance )
#
# exhibition.Artist_ID can be joined with artist.Artist_ID
# exhibition_record.Exhibition_ID can be joined with exhibition.Exhibition_ID
#
### Question:
#
# Return the name of the artist who has the latest join year.
#
### SQL:
#
# SELECT name FROM artist ORDER BY year_join DESC LIMIT 1
#
### End.
|
theme_gallery
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# artist ( Artist_ID, Name, Country, Year_Join, Age )
# exhibition ( Exhibition_ID, Year, Theme, Artist_ID, Ticket_Price )
# exhibition_record ( Exhibition_ID, Date, Attendance )
#
# exhibition.Artist_ID can be joined with artist.Artist_ID
# exhibition_record.Exhibition_ID can be joined with exhibition.Exhibition_ID
#
### Question:
#
# How many exhibition are there in year 2005 or after?
#
### SQL:
#
# SELECT count(*) FROM exhibition WHERE YEAR >= 2005
#
### End.
|
theme_gallery
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# artist ( Artist_ID, Name, Country, Year_Join, Age )
# exhibition ( Exhibition_ID, Year, Theme, Artist_ID, Ticket_Price )
# exhibition_record ( Exhibition_ID, Date, Attendance )
#
# exhibition.Artist_ID can be joined with artist.Artist_ID
# exhibition_record.Exhibition_ID can be joined with exhibition.Exhibition_ID
#
### Question:
#
# Count the number of exhibitions that happened in or after 2005.
#
### SQL:
#
# SELECT count(*) FROM exhibition WHERE YEAR >= 2005
#
### End.
|
theme_gallery
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# artist ( Artist_ID, Name, Country, Year_Join, Age )
# exhibition ( Exhibition_ID, Year, Theme, Artist_ID, Ticket_Price )
# exhibition_record ( Exhibition_ID, Date, Attendance )
#
# exhibition.Artist_ID can be joined with artist.Artist_ID
# exhibition_record.Exhibition_ID can be joined with exhibition.Exhibition_ID
#
### Question:
#
# Show theme and year for all exhibitions with ticket prices lower than 15.
#
### SQL:
#
# SELECT theme , YEAR FROM exhibition WHERE ticket_price < 15
#
### End.
|
theme_gallery
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# artist ( Artist_ID, Name, Country, Year_Join, Age )
# exhibition ( Exhibition_ID, Year, Theme, Artist_ID, Ticket_Price )
# exhibition_record ( Exhibition_ID, Date, Attendance )
#
# exhibition.Artist_ID can be joined with artist.Artist_ID
# exhibition_record.Exhibition_ID can be joined with exhibition.Exhibition_ID
#
### Question:
#
# What are the theme and year for all exhibitions that have a ticket price under 15?
#
### SQL:
#
# SELECT theme , YEAR FROM exhibition WHERE ticket_price < 15
#
### End.
|
theme_gallery
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# artist ( Artist_ID, Name, Country, Year_Join, Age )
# exhibition ( Exhibition_ID, Year, Theme, Artist_ID, Ticket_Price )
# exhibition_record ( Exhibition_ID, Date, Attendance )
#
# exhibition.Artist_ID can be joined with artist.Artist_ID
# exhibition_record.Exhibition_ID can be joined with exhibition.Exhibition_ID
#
### Question:
#
# Show all artist names and the number of exhibitions for each artist.
#
### SQL:
#
# SELECT T2.name , count(*) FROM exhibition AS T1 JOIN artist AS T2 ON T1.artist_id = T2.artist_id GROUP BY T1.artist_id
#
### End.
|
theme_gallery
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# artist ( Artist_ID, Name, Country, Year_Join, Age )
# exhibition ( Exhibition_ID, Year, Theme, Artist_ID, Ticket_Price )
# exhibition_record ( Exhibition_ID, Date, Attendance )
#
# exhibition.Artist_ID can be joined with artist.Artist_ID
# exhibition_record.Exhibition_ID can be joined with exhibition.Exhibition_ID
#
### Question:
#
# How many exhibitions has each artist had?
#
### SQL:
#
# SELECT T2.name , count(*) FROM exhibition AS T1 JOIN artist AS T2 ON T1.artist_id = T2.artist_id GROUP BY T1.artist_id
#
### End.
|
theme_gallery
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# artist ( Artist_ID, Name, Country, Year_Join, Age )
# exhibition ( Exhibition_ID, Year, Theme, Artist_ID, Ticket_Price )
# exhibition_record ( Exhibition_ID, Date, Attendance )
#
# exhibition.Artist_ID can be joined with artist.Artist_ID
# exhibition_record.Exhibition_ID can be joined with exhibition.Exhibition_ID
#
### Question:
#
# What is the name and country for the artist with most number of exhibitions?
#
### SQL:
#
# 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
#
### End.
|
theme_gallery
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# artist ( Artist_ID, Name, Country, Year_Join, Age )
# exhibition ( Exhibition_ID, Year, Theme, Artist_ID, Ticket_Price )
# exhibition_record ( Exhibition_ID, Date, Attendance )
#
# exhibition.Artist_ID can be joined with artist.Artist_ID
# exhibition_record.Exhibition_ID can be joined with exhibition.Exhibition_ID
#
### Question:
#
# Return the name and country corresponding to the artist who has had the most exhibitions.
#
### SQL:
#
# 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
#
### End.
|
theme_gallery
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# artist ( Artist_ID, Name, Country, Year_Join, Age )
# exhibition ( Exhibition_ID, Year, Theme, Artist_ID, Ticket_Price )
# exhibition_record ( Exhibition_ID, Date, Attendance )
#
# exhibition.Artist_ID can be joined with artist.Artist_ID
# exhibition_record.Exhibition_ID can be joined with exhibition.Exhibition_ID
#
### Question:
#
# Show names for artists without any exhibition.
#
### SQL:
#
# SELECT name FROM artist WHERE artist_id NOT IN (SELECT artist_id FROM exhibition)
#
### End.
|
theme_gallery
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# artist ( Artist_ID, Name, Country, Year_Join, Age )
# exhibition ( Exhibition_ID, Year, Theme, Artist_ID, Ticket_Price )
# exhibition_record ( Exhibition_ID, Date, Attendance )
#
# exhibition.Artist_ID can be joined with artist.Artist_ID
# exhibition_record.Exhibition_ID can be joined with exhibition.Exhibition_ID
#
### Question:
#
# What are the names of artists that have not had any exhibitions?
#
### SQL:
#
# SELECT name FROM artist WHERE artist_id NOT IN (SELECT artist_id FROM exhibition)
#
### End.
|
theme_gallery
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# artist ( Artist_ID, Name, Country, Year_Join, Age )
# exhibition ( Exhibition_ID, Year, Theme, Artist_ID, Ticket_Price )
# exhibition_record ( Exhibition_ID, Date, Attendance )
#
# exhibition.Artist_ID can be joined with artist.Artist_ID
# exhibition_record.Exhibition_ID can be joined with exhibition.Exhibition_ID
#
### Question:
#
# What is the theme and artist name for the exhibition with a ticket price higher than the average?
#
### SQL:
#
# 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)
#
### End.
|
theme_gallery
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# artist ( Artist_ID, Name, Country, Year_Join, Age )
# exhibition ( Exhibition_ID, Year, Theme, Artist_ID, Ticket_Price )
# exhibition_record ( Exhibition_ID, Date, Attendance )
#
# exhibition.Artist_ID can be joined with artist.Artist_ID
# exhibition_record.Exhibition_ID can be joined with exhibition.Exhibition_ID
#
### Question:
#
# Return the names of artists and the themes of their exhibitions that had a ticket price higher than average.
#
### SQL:
#
# 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)
#
### End.
|
theme_gallery
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# artist ( Artist_ID, Name, Country, Year_Join, Age )
# exhibition ( Exhibition_ID, Year, Theme, Artist_ID, Ticket_Price )
# exhibition_record ( Exhibition_ID, Date, Attendance )
#
# exhibition.Artist_ID can be joined with artist.Artist_ID
# exhibition_record.Exhibition_ID can be joined with exhibition.Exhibition_ID
#
### Question:
#
# Show the average, minimum, and maximum ticket prices for exhibitions for all years before 2009.
#
### SQL:
#
# SELECT avg(ticket_price) , min(ticket_price) , max(ticket_price) FROM exhibition WHERE YEAR < 2009
#
### End.
|
theme_gallery
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# artist ( Artist_ID, Name, Country, Year_Join, Age )
# exhibition ( Exhibition_ID, Year, Theme, Artist_ID, Ticket_Price )
# exhibition_record ( Exhibition_ID, Date, Attendance )
#
# exhibition.Artist_ID can be joined with artist.Artist_ID
# exhibition_record.Exhibition_ID can be joined with exhibition.Exhibition_ID
#
### Question:
#
# What are the average, minimum, and maximum ticket prices for exhibitions that happened prior to 2009?
#
### SQL:
#
# SELECT avg(ticket_price) , min(ticket_price) , max(ticket_price) FROM exhibition WHERE YEAR < 2009
#
### End.
|
theme_gallery
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# artist ( Artist_ID, Name, Country, Year_Join, Age )
# exhibition ( Exhibition_ID, Year, Theme, Artist_ID, Ticket_Price )
# exhibition_record ( Exhibition_ID, Date, Attendance )
#
# exhibition.Artist_ID can be joined with artist.Artist_ID
# exhibition_record.Exhibition_ID can be joined with exhibition.Exhibition_ID
#
### Question:
#
# Show theme and year for all exhibitions in an descending order of ticket price.
#
### SQL:
#
# SELECT theme , YEAR FROM exhibition ORDER BY ticket_price DESC
#
### End.
|
theme_gallery
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# artist ( Artist_ID, Name, Country, Year_Join, Age )
# exhibition ( Exhibition_ID, Year, Theme, Artist_ID, Ticket_Price )
# exhibition_record ( Exhibition_ID, Date, Attendance )
#
# exhibition.Artist_ID can be joined with artist.Artist_ID
# exhibition_record.Exhibition_ID can be joined with exhibition.Exhibition_ID
#
### Question:
#
# What are the themes and years for exhibitions, sorted by ticket price descending?
#
### SQL:
#
# SELECT theme , YEAR FROM exhibition ORDER BY ticket_price DESC
#
### End.
|
theme_gallery
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# artist ( Artist_ID, Name, Country, Year_Join, Age )
# exhibition ( Exhibition_ID, Year, Theme, Artist_ID, Ticket_Price )
# exhibition_record ( Exhibition_ID, Date, Attendance )
#
# exhibition.Artist_ID can be joined with artist.Artist_ID
# exhibition_record.Exhibition_ID can be joined with exhibition.Exhibition_ID
#
### Question:
#
# What is the theme, date, and attendance for the exhibition in year 2004?
#
### SQL:
#
# 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
#
### End.
|
theme_gallery
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# artist ( Artist_ID, Name, Country, Year_Join, Age )
# exhibition ( Exhibition_ID, Year, Theme, Artist_ID, Ticket_Price )
# exhibition_record ( Exhibition_ID, Date, Attendance )
#
# exhibition.Artist_ID can be joined with artist.Artist_ID
# exhibition_record.Exhibition_ID can be joined with exhibition.Exhibition_ID
#
### Question:
#
# Return the themes, dates, and attendance for exhibitions that happened in 2004.
#
### SQL:
#
# 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
#
### End.
|
theme_gallery
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# artist ( Artist_ID, Name, Country, Year_Join, Age )
# exhibition ( Exhibition_ID, Year, Theme, Artist_ID, Ticket_Price )
# exhibition_record ( Exhibition_ID, Date, Attendance )
#
# exhibition.Artist_ID can be joined with artist.Artist_ID
# exhibition_record.Exhibition_ID can be joined with exhibition.Exhibition_ID
#
### Question:
#
# Show all artist names who didn't have an exhibition in 2004.
#
### SQL:
#
# 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
#
### End.
|
theme_gallery
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# artist ( Artist_ID, Name, Country, Year_Join, Age )
# exhibition ( Exhibition_ID, Year, Theme, Artist_ID, Ticket_Price )
# exhibition_record ( Exhibition_ID, Date, Attendance )
#
# exhibition.Artist_ID can be joined with artist.Artist_ID
# exhibition_record.Exhibition_ID can be joined with exhibition.Exhibition_ID
#
### Question:
#
# What are the names of artists who did not have an exhibition in 2004?
#
### SQL:
#
# 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
#
### End.
|
theme_gallery
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# artist ( Artist_ID, Name, Country, Year_Join, Age )
# exhibition ( Exhibition_ID, Year, Theme, Artist_ID, Ticket_Price )
# exhibition_record ( Exhibition_ID, Date, Attendance )
#
# exhibition.Artist_ID can be joined with artist.Artist_ID
# exhibition_record.Exhibition_ID can be joined with exhibition.Exhibition_ID
#
### Question:
#
# Show the theme for exhibitions with both records of an attendance below 100 and above 500.
#
### SQL:
#
# 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
#
### End.
|
theme_gallery
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# artist ( Artist_ID, Name, Country, Year_Join, Age )
# exhibition ( Exhibition_ID, Year, Theme, Artist_ID, Ticket_Price )
# exhibition_record ( Exhibition_ID, Date, Attendance )
#
# exhibition.Artist_ID can be joined with artist.Artist_ID
# exhibition_record.Exhibition_ID can be joined with exhibition.Exhibition_ID
#
### Question:
#
# Which themes have had corresponding exhibitions that have had attendance both below 100 and above 500?
#
### SQL:
#
# 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
#
### End.
|
theme_gallery
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# artist ( Artist_ID, Name, Country, Year_Join, Age )
# exhibition ( Exhibition_ID, Year, Theme, Artist_ID, Ticket_Price )
# exhibition_record ( Exhibition_ID, Date, Attendance )
#
# exhibition.Artist_ID can be joined with artist.Artist_ID
# exhibition_record.Exhibition_ID can be joined with exhibition.Exhibition_ID
#
### Question:
#
# How many exhibitions have a attendance more than 100 or have a ticket price below 10?
#
### SQL:
#
# 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
#
### End.
|
theme_gallery
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# artist ( Artist_ID, Name, Country, Year_Join, Age )
# exhibition ( Exhibition_ID, Year, Theme, Artist_ID, Ticket_Price )
# exhibition_record ( Exhibition_ID, Date, Attendance )
#
# exhibition.Artist_ID can be joined with artist.Artist_ID
# exhibition_record.Exhibition_ID can be joined with exhibition.Exhibition_ID
#
### Question:
#
# Count the number of exhibitions that have had an attendnance of over 100 or a ticket prices under 10.
#
### SQL:
#
# 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
#
### End.
|
theme_gallery
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# artist ( Artist_ID, Name, Country, Year_Join, Age )
# exhibition ( Exhibition_ID, Year, Theme, Artist_ID, Ticket_Price )
# exhibition_record ( Exhibition_ID, Date, Attendance )
#
# exhibition.Artist_ID can be joined with artist.Artist_ID
# exhibition_record.Exhibition_ID can be joined with exhibition.Exhibition_ID
#
### Question:
#
# Show all artist names with an average exhibition attendance over 200.
#
### SQL:
#
# 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
#
### End.
|
theme_gallery
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# artist ( Artist_ID, Name, Country, Year_Join, Age )
# exhibition ( Exhibition_ID, Year, Theme, Artist_ID, Ticket_Price )
# exhibition_record ( Exhibition_ID, Date, Attendance )
#
# exhibition.Artist_ID can be joined with artist.Artist_ID
# exhibition_record.Exhibition_ID can be joined with exhibition.Exhibition_ID
#
### Question:
#
# What are the names of artist whose exhibitions draw over 200 attendees on average?
#
### SQL:
#
# 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
#
### End.
|
epinions_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# item ( i_id, title )
# review ( a_id, u_id, i_id, rating, rank )
# useracct ( u_id, name )
# trust ( source_u_id, target_u_id, trust )
#
# review.i_id can be joined with item.i_id
# review.u_id can be joined with useracct.u_id
# trust.target_u_id can be joined with useracct.u_id
# trust.source_u_id can be joined with useracct.u_id
#
### Question:
#
# Find the id of the item whose title is "orange".
#
### SQL:
#
# SELECT i_id FROM item WHERE title = "orange"
#
### End.
|
epinions_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# item ( i_id, title )
# review ( a_id, u_id, i_id, rating, rank )
# useracct ( u_id, name )
# trust ( source_u_id, target_u_id, trust )
#
# review.i_id can be joined with item.i_id
# review.u_id can be joined with useracct.u_id
# trust.target_u_id can be joined with useracct.u_id
# trust.source_u_id can be joined with useracct.u_id
#
### Question:
#
# List all information in the item table.
#
### SQL:
#
# SELECT * FROM item
#
### End.
|
epinions_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# item ( i_id, title )
# review ( a_id, u_id, i_id, rating, rank )
# useracct ( u_id, name )
# trust ( source_u_id, target_u_id, trust )
#
# review.i_id can be joined with item.i_id
# review.u_id can be joined with useracct.u_id
# trust.target_u_id can be joined with useracct.u_id
# trust.source_u_id can be joined with useracct.u_id
#
### Question:
#
# Find the number of reviews.
#
### SQL:
#
# SELECT count(*) FROM review
#
### End.
|
epinions_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# item ( i_id, title )
# review ( a_id, u_id, i_id, rating, rank )
# useracct ( u_id, name )
# trust ( source_u_id, target_u_id, trust )
#
# review.i_id can be joined with item.i_id
# review.u_id can be joined with useracct.u_id
# trust.target_u_id can be joined with useracct.u_id
# trust.source_u_id can be joined with useracct.u_id
#
### Question:
#
# How many users are there?
#
### SQL:
#
# SELECT count(*) FROM useracct
#
### End.
|
epinions_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# item ( i_id, title )
# review ( a_id, u_id, i_id, rating, rank )
# useracct ( u_id, name )
# trust ( source_u_id, target_u_id, trust )
#
# review.i_id can be joined with item.i_id
# review.u_id can be joined with useracct.u_id
# trust.target_u_id can be joined with useracct.u_id
# trust.source_u_id can be joined with useracct.u_id
#
### Question:
#
# Find the average and maximum rating of all reviews.
#
### SQL:
#
# SELECT avg(rating) , max(rating) FROM review
#
### End.
|
epinions_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# item ( i_id, title )
# review ( a_id, u_id, i_id, rating, rank )
# useracct ( u_id, name )
# trust ( source_u_id, target_u_id, trust )
#
# review.i_id can be joined with item.i_id
# review.u_id can be joined with useracct.u_id
# trust.target_u_id can be joined with useracct.u_id
# trust.source_u_id can be joined with useracct.u_id
#
### Question:
#
# Find the highest rank of all reviews.
#
### SQL:
#
# SELECT min(rank) FROM review
#
### End.
|
epinions_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# item ( i_id, title )
# review ( a_id, u_id, i_id, rating, rank )
# useracct ( u_id, name )
# trust ( source_u_id, target_u_id, trust )
#
# review.i_id can be joined with item.i_id
# review.u_id can be joined with useracct.u_id
# trust.target_u_id can be joined with useracct.u_id
# trust.source_u_id can be joined with useracct.u_id
#
### Question:
#
# How many different users wrote some reviews?
#
### SQL:
#
# SELECT count(DISTINCT u_id) FROM review
#
### End.
|
epinions_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# item ( i_id, title )
# review ( a_id, u_id, i_id, rating, rank )
# useracct ( u_id, name )
# trust ( source_u_id, target_u_id, trust )
#
# review.i_id can be joined with item.i_id
# review.u_id can be joined with useracct.u_id
# trust.target_u_id can be joined with useracct.u_id
# trust.source_u_id can be joined with useracct.u_id
#
### Question:
#
# How many different items were reviewed by some users?
#
### SQL:
#
# SELECT count(DISTINCT i_id) FROM review
#
### End.
|
epinions_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# item ( i_id, title )
# review ( a_id, u_id, i_id, rating, rank )
# useracct ( u_id, name )
# trust ( source_u_id, target_u_id, trust )
#
# review.i_id can be joined with item.i_id
# review.u_id can be joined with useracct.u_id
# trust.target_u_id can be joined with useracct.u_id
# trust.source_u_id can be joined with useracct.u_id
#
### Question:
#
# Find the number of items that did not receive any review.
#
### SQL:
#
# SELECT count(*) FROM item WHERE i_id NOT IN (SELECT i_id FROM review)
#
### End.
|
epinions_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# item ( i_id, title )
# review ( a_id, u_id, i_id, rating, rank )
# useracct ( u_id, name )
# trust ( source_u_id, target_u_id, trust )
#
# review.i_id can be joined with item.i_id
# review.u_id can be joined with useracct.u_id
# trust.target_u_id can be joined with useracct.u_id
# trust.source_u_id can be joined with useracct.u_id
#
### Question:
#
# Find the names of users who did not leave any review.
#
### SQL:
#
# SELECT name FROM useracct WHERE u_id NOT IN (SELECT u_id FROM review)
#
### End.
|
epinions_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# item ( i_id, title )
# review ( a_id, u_id, i_id, rating, rank )
# useracct ( u_id, name )
# trust ( source_u_id, target_u_id, trust )
#
# review.i_id can be joined with item.i_id
# review.u_id can be joined with useracct.u_id
# trust.target_u_id can be joined with useracct.u_id
# trust.source_u_id can be joined with useracct.u_id
#
### Question:
#
# Find the names of goods that receive a rating of 10.
#
### SQL:
#
# SELECT T1.title FROM item AS T1 JOIN review AS T2 ON T1.i_id = T2.i_id WHERE T2.rating = 10
#
### End.
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.