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