db_id
stringclasses
146 values
question_en
stringlengths
3
224
hardness
stringclasses
4 values
schema_llm
stringclasses
146 values
query_llm
stringlengths
18
631
schema_llm_min
stringclasses
147 values
schema_dict
stringclasses
146 values
tables_and_columns
stringlengths
18
266
schema_reduzido
stringlengths
25
718
schema_reduzido_only_tables
stringlengths
80
2.27k
customers_card_transactions
What are card ids, customer ids, card types, and card numbers for each customer card?
medium
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT card_id , customer_id , card_type_code , card_number FROM Customers_cards
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number'] }
TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), ) Possible JOINs:
TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Possible JOINs:
customers_card_transactions
Show the date valid from and the date valid to for the card with card number '4560596484842'.
medium
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT date_valid_from , date_valid_to FROM Customers_cards WHERE card_number = "4560596484842"
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'customers_cards': ['card_id', 'card_number', 'date_valid_from', 'date_valid_to'] }
TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), ) Possible JOINs:
TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Possible JOINs:
customers_card_transactions
What are the valid from and valid to dates for the card with the number 4560596484842?
medium
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT date_valid_from , date_valid_to FROM Customers_cards WHERE card_number = "4560596484842"
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'customers_cards': ['card_id', 'card_number', 'date_valid_from', 'date_valid_to'] }
TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), ) Possible JOINs:
TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Possible JOINs:
customers_card_transactions
What is the first name, last name, and phone of the customer with card 4560596484842.
medium
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT Customers.customer_first_name , Customers.customer_last_name , Customers.customer_phone FROM Customers_cards JOIN Customers ON Customers_cards.customer_id = Customers.customer_id WHERE Customers_cards.card_number = "4560596484842"
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'customers_cards': ['card_id', 'customer_id', 'card_number'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_phone'] }
TABLE Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_phone (VARCHAR(255)), ) TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_number (VARCHAR(80)), ) Possible JOINs:
TABLE Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Possible JOINs:
customers_card_transactions
Return the full name and phone of the customer who has card number 4560596484842.
medium
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT Customers.customer_first_name , Customers.customer_last_name , Customers.customer_phone FROM Customers_cards JOIN Customers ON Customers_cards.customer_id = Customers.customer_id WHERE Customers_cards.card_number = "4560596484842"
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'customers_cards': ['card_id', 'customer_id', 'card_number'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_phone'] }
TABLE Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_phone (VARCHAR(255)), ) TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_number (VARCHAR(80)), ) Possible JOINs:
TABLE Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Possible JOINs:
customers_card_transactions
How many cards does customer Art Turcotte have?
medium
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT count(*) FROM Customers_cards JOIN Customers ON Customers_cards.customer_id = Customers.customer_id WHERE Customers.customer_first_name = "Art" AND Customers.customer_last_name = "Turcotte"
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'customers_cards': ['card_id', 'customer_id'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name'] }
TABLE Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), ) TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), ) Possible JOINs:
TABLE Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Possible JOINs:
customers_card_transactions
Count the number of cards the customer with the first name Art and last name Turcotte has.
medium
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT count(*) FROM Customers_cards JOIN Customers ON Customers_cards.customer_id = Customers.customer_id WHERE Customers.customer_first_name = "Art" AND Customers.customer_last_name = "Turcotte"
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'customers_cards': ['card_id', 'customer_id'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name'] }
TABLE Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), ) TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), ) Possible JOINs:
TABLE Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Possible JOINs:
customers_card_transactions
How many debit cards do we have?
easy
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT count(*) FROM Customers_cards WHERE card_type_code = "Debit"
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'customers_cards': ['card_id', 'card_type_code'] }
TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), ) Possible JOINs:
TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Possible JOINs:
customers_card_transactions
Count the number of customer cards of the type Debit.
easy
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT count(*) FROM Customers_cards WHERE card_type_code = "Debit"
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'customers_cards': ['card_id', 'card_type_code'] }
TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), ) Possible JOINs:
TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Possible JOINs:
customers_card_transactions
How many credit cards does customer Blanche Huels have?
medium
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT count(*) FROM Customers_cards JOIN Customers ON Customers_cards.customer_id = Customers.customer_id WHERE Customers.customer_first_name = "Blanche" AND Customers.customer_last_name = "Huels" AND Customers_cards.card_type_code = "Credit"
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'customers_cards': ['card_id', 'customer_id', 'card_type_code'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name'] }
TABLE Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), ) TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), ) Possible JOINs:
TABLE Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Possible JOINs:
customers_card_transactions
Count the number of credit cards that the customer with first name Blanche and last name Huels has.
medium
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT count(*) FROM Customers_cards JOIN Customers ON Customers_cards.customer_id = Customers.customer_id WHERE Customers.customer_first_name = "Blanche" AND Customers.customer_last_name = "Huels" AND Customers_cards.card_type_code = "Credit"
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'customers_cards': ['card_id', 'customer_id', 'card_type_code'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name'] }
TABLE Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), ) TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), ) Possible JOINs:
TABLE Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Possible JOINs:
customers_card_transactions
Show all customer ids and the number of cards owned by each customer.
medium
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT customer_id , count(*) FROM Customers_cards GROUP BY customer_id
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'customers_cards': ['card_id', 'customer_id'] }
TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), ) Possible JOINs:
TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Possible JOINs:
customers_card_transactions
What are the different customer ids, and how many cards does each one hold?
medium
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT customer_id , count(*) FROM Customers_cards GROUP BY customer_id
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'customers_cards': ['card_id', 'customer_id'] }
TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), ) Possible JOINs:
TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Possible JOINs:
customers_card_transactions
What is the customer id with most number of cards, and how many does he have?
hard
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT customer_id , count(*) FROM Customers_cards GROUP BY customer_id ORDER BY count(*) DESC LIMIT 1
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'customers_cards': ['card_id', 'customer_id'] }
TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), ) Possible JOINs:
TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Possible JOINs:
customers_card_transactions
Return the id of the customer who has the most cards, as well as the number of cards.
hard
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT customer_id , count(*) FROM Customers_cards GROUP BY customer_id ORDER BY count(*) DESC LIMIT 1
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'customers_cards': ['card_id', 'customer_id'] }
TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), ) Possible JOINs:
TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Possible JOINs:
customers_card_transactions
Show id, first and last names for all customers with at least two cards.
medium
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT Customers_cards.customer_id , Customers.customer_first_name , Customers.customer_last_name FROM Customers_cards JOIN Customers ON Customers_cards.customer_id = Customers.customer_id GROUP BY Customers_cards.customer_id HAVING count(*) >= 2
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'customers_cards': ['card_id', 'customer_id'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name'] }
TABLE Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), ) TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), ) Possible JOINs:
TABLE Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Possible JOINs:
customers_card_transactions
What are the ids and full names of customers who hold two or more cards?
medium
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT Customers_cards.customer_id , Customers.customer_first_name , Customers.customer_last_name FROM Customers_cards JOIN Customers ON Customers_cards.customer_id = Customers.customer_id GROUP BY Customers_cards.customer_id HAVING count(*) >= 2
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'customers_cards': ['card_id', 'customer_id'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name'] }
TABLE Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), ) TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), ) Possible JOINs:
TABLE Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Possible JOINs:
customers_card_transactions
What is the customer id, first and last name with least number of accounts.
extra
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT Customers_cards.customer_id , Customers.customer_first_name , Customers.customer_last_name FROM Customers_cards JOIN Customers ON Customers_cards.customer_id = Customers.customer_id GROUP BY Customers_cards.customer_id ORDER BY count(*) ASC LIMIT 1
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'customers_cards': ['card_id', 'customer_id'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name'] }
TABLE Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), ) TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), ) Possible JOINs:
TABLE Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Possible JOINs:
customers_card_transactions
Return the id and full name of the customer who has the fewest accounts.
extra
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT Customers_cards.customer_id , Customers.customer_first_name , Customers.customer_last_name FROM Customers_cards JOIN Customers ON Customers_cards.customer_id = Customers.customer_id GROUP BY Customers_cards.customer_id ORDER BY count(*) ASC LIMIT 1
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'customers_cards': ['card_id', 'customer_id'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name'] }
TABLE Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), ) TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), ) Possible JOINs:
TABLE Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Possible JOINs:
customers_card_transactions
Show all card type codes and the number of cards in each type.
medium
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT card_type_code , count(*) FROM Customers_cards GROUP BY card_type_code
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'customers_cards': ['card_id', 'card_type_code'] }
TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), ) Possible JOINs:
TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Possible JOINs:
customers_card_transactions
What are the different card types, and how many cards are there of each?
medium
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT card_type_code , count(*) FROM Customers_cards GROUP BY card_type_code
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'customers_cards': ['card_id', 'card_type_code'] }
TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), ) Possible JOINs:
TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Possible JOINs:
customers_card_transactions
What is the card type code with most number of cards?
hard
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT card_type_code FROM Customers_cards GROUP BY card_type_code ORDER BY count(*) DESC LIMIT 1
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'customers_cards': ['card_id', 'card_type_code'] }
TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), ) Possible JOINs:
TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Possible JOINs:
customers_card_transactions
Return the code of the card type that is most common.
hard
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT card_type_code FROM Customers_cards GROUP BY card_type_code ORDER BY count(*) DESC LIMIT 1
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'customers_cards': ['card_id', 'card_type_code'] }
TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), ) Possible JOINs:
TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Possible JOINs:
customers_card_transactions
Show card type codes with at least 5 cards.
easy
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT card_type_code FROM Customers_cards GROUP BY card_type_code HAVING count(*) >= 5
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'customers_cards': ['card_id', 'card_type_code'] }
TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), ) Possible JOINs:
TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Possible JOINs:
customers_card_transactions
What are the codes of card types that have 5 or more cards?
easy
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT card_type_code FROM Customers_cards GROUP BY card_type_code HAVING count(*) >= 5
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'customers_cards': ['card_id', 'card_type_code'] }
TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), ) Possible JOINs:
TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Possible JOINs:
customers_card_transactions
Show all card type codes and the number of customers holding cards in each type.
medium
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT card_type_code , count(DISTINCT customer_id) FROM Customers_cards GROUP BY card_type_code
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'customers_cards': ['card_id', 'customer_id', 'card_type_code'] }
TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), ) Possible JOINs:
TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Possible JOINs:
customers_card_transactions
What are the different card type codes, and how many different customers hold each type?
medium
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT card_type_code , count(DISTINCT customer_id) FROM Customers_cards GROUP BY card_type_code
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'customers_cards': ['card_id', 'customer_id', 'card_type_code'] }
TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), ) Possible JOINs:
TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Possible JOINs:
customers_card_transactions
Show the customer ids and firstname without a credit card.
extra
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT customer_id , customer_first_name FROM Customers EXCEPT SELECT Customers_cards.customer_id , Customers.customer_first_name FROM Customers_cards JOIN Customers ON Customers_cards.customer_id = Customers.customer_id WHERE card_type_code = "Credit"
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'customers': ['customer_id', 'customer_first_name'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code'] }
TABLE Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), ) TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), ) Possible JOINs:
TABLE Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Possible JOINs:
customers_card_transactions
What are the ids and first names of customers who do not hold a credit card?
extra
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT customer_id , customer_first_name FROM Customers EXCEPT SELECT Customers_cards.customer_id , Customers.customer_first_name FROM Customers_cards JOIN Customers ON Customers_cards.customer_id = Customers.customer_id WHERE card_type_code = "Credit"
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'customers': ['customer_id', 'customer_first_name'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code'] }
TABLE Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), ) TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), ) Possible JOINs:
TABLE Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Possible JOINs:
customers_card_transactions
Show all card type codes.
easy
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT DISTINCT card_type_code FROM Customers_Cards
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'customers_cards': ['card_id', 'card_type_code'] }
TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), ) Possible JOINs:
TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Possible JOINs:
customers_card_transactions
What are the different card type codes?
easy
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT DISTINCT card_type_code FROM Customers_Cards
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'customers_cards': ['card_id', 'card_type_code'] }
TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), ) Possible JOINs:
TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Possible JOINs:
customers_card_transactions
Show the number of card types.
easy
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT count(DISTINCT card_type_code) FROM Customers_Cards
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'customers_cards': ['card_id', 'card_type_code'] }
TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), ) Possible JOINs:
TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Possible JOINs:
customers_card_transactions
How many different card types are there?
easy
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT count(DISTINCT card_type_code) FROM Customers_Cards
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'customers_cards': ['card_id', 'card_type_code'] }
TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), ) Possible JOINs:
TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Possible JOINs:
customers_card_transactions
Show all transaction types.
easy
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT DISTINCT transaction_type FROM Financial_Transactions
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'financial_transactions': ['transaction_type'] }
TABLE Financial_Transactions ( Financial_Transactions.transaction_type (VARCHAR(15)), )
TABLE Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
customers_card_transactions
What are the different types of transactions?
easy
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT DISTINCT transaction_type FROM Financial_Transactions
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'financial_transactions': ['transaction_type'] }
TABLE Financial_Transactions ( Financial_Transactions.transaction_type (VARCHAR(15)), )
TABLE Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
customers_card_transactions
Show the number of transaction types.
easy
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT count(DISTINCT transaction_type) FROM Financial_Transactions
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'financial_transactions': ['transaction_type'] }
TABLE Financial_Transactions ( Financial_Transactions.transaction_type (VARCHAR(15)), )
TABLE Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
customers_card_transactions
How many different types of transactions are there?
easy
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT count(DISTINCT transaction_type) FROM Financial_Transactions
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'financial_transactions': ['transaction_type'] }
TABLE Financial_Transactions ( Financial_Transactions.transaction_type (VARCHAR(15)), )
TABLE Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
customers_card_transactions
What is the average and total transaction amount?
medium
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT avg(transaction_amount) , sum(transaction_amount) FROM Financial_transactions
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'financial_transactions': ['transaction_amount'] }
TABLE Financial_Transactions ( Financial_Transactions.transaction_amount (DOUBLE), )
TABLE Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
customers_card_transactions
Return the average transaction amount, as well as the total amount of all transactions.
medium
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT avg(transaction_amount) , sum(transaction_amount) FROM Financial_transactions
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'financial_transactions': ['transaction_amount'] }
TABLE Financial_Transactions ( Financial_Transactions.transaction_amount (DOUBLE), )
TABLE Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
customers_card_transactions
Show the card type codes and the number of transactions.
medium
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT Customers_cards.card_type_code , count(*) FROM Financial_transactions JOIN Customers_cards ON Financial_transactions.card_id = Customers_cards.card_id GROUP BY Customers_cards.card_type_code
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'financial_transactions': ['card_id'], 'customers_cards': ['card_id', 'card_type_code'] }
TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), ) TABLE Financial_Transactions ( Financial_Transactions.card_id (INTEGER), ) Possible JOINs: Financial_Transactions.card_id = Customers_Cards.card_id
TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) TABLE Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
customers_card_transactions
What are the different card types, and how many transactions have been made with each?
medium
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT Customers_cards.card_type_code , count(*) FROM Financial_transactions JOIN Customers_cards ON Financial_transactions.card_id = Customers_cards.card_id GROUP BY Customers_cards.card_type_code
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'financial_transactions': ['card_id'], 'customers_cards': ['card_id', 'card_type_code'] }
TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), ) TABLE Financial_Transactions ( Financial_Transactions.card_id (INTEGER), ) Possible JOINs: Financial_Transactions.card_id = Customers_Cards.card_id
TABLE Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) TABLE Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
customers_card_transactions
Show the transaction type and the number of transactions.
medium
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT transaction_type , count(*) FROM Financial_transactions GROUP BY transaction_type
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'financial_transactions': ['transaction_type'] }
TABLE Financial_Transactions ( Financial_Transactions.transaction_type (VARCHAR(15)), )
TABLE Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
customers_card_transactions
What are the different transaction types, and how many transactions of each have taken place?
medium
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT transaction_type , count(*) FROM Financial_transactions GROUP BY transaction_type
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'financial_transactions': ['transaction_type'] }
TABLE Financial_Transactions ( Financial_Transactions.transaction_type (VARCHAR(15)), )
TABLE Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
customers_card_transactions
What is the transaction type that has processed the greatest total amount in transactions?
hard
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT transaction_type FROM Financial_transactions GROUP BY transaction_type ORDER BY sum(transaction_amount) DESC LIMIT 1
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'financial_transactions': ['transaction_type', 'transaction_amount'] }
TABLE Financial_Transactions ( Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_amount (DOUBLE), )
TABLE Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
customers_card_transactions
Return the type of transaction with the highest total amount.
hard
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT transaction_type FROM Financial_transactions GROUP BY transaction_type ORDER BY sum(transaction_amount) DESC LIMIT 1
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'financial_transactions': ['transaction_type', 'transaction_amount'] }
TABLE Financial_Transactions ( Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_amount (DOUBLE), )
TABLE Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
customers_card_transactions
Show the account id and the number of transactions for each account
medium
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT account_id , count(*) FROM Financial_transactions GROUP BY account_id
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'financial_transactions': ['account_id'] }
TABLE Financial_Transactions ( Financial_Transactions.account_id (INTEGER), )
TABLE Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
customers_card_transactions
What are the different account ids that have made financial transactions, as well as how many transactions correspond to each?
medium
Table Accounts ( Accounts.account_id (INTEGER), Accounts.customer_id (INTEGER), Accounts.account_name (VARCHAR(50)), Accounts.other_account_details (VARCHAR(255)), ) Table Customers ( Customers.customer_id (INTEGER), Customers.customer_first_name (VARCHAR(20)), Customers.customer_last_name (VARCHAR(20)), Customers.customer_address (VARCHAR(255)), Customers.customer_phone (VARCHAR(255)), Customers.customer_email (VARCHAR(255)), Customers.other_customer_details (VARCHAR(255)), ) Table Customers_Cards ( Customers_Cards.card_id (INTEGER), Customers_Cards.customer_id (INTEGER), Customers_Cards.card_type_code (VARCHAR(15)), Customers_Cards.card_number (VARCHAR(80)), Customers_Cards.date_valid_from (DATETIME), Customers_Cards.date_valid_to (DATETIME), Customers_Cards.other_card_details (VARCHAR(255)), ) Table Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
SELECT account_id , count(*) FROM Financial_transactions GROUP BY account_id
Table accounts ( accounts.account_id (INTEGER), accounts.customer_id (INTEGER), accounts.account_name (VARCHAR(50)), accounts.other_account_details (VARCHAR(255)), ) Table customers ( customers.customer_id (INTEGER), customers.customer_first_name (VARCHAR(20)), customers.customer_last_name (VARCHAR(20)), customers.customer_address (VARCHAR(255)), customers.customer_phone (VARCHAR(255)), customers.customer_email (VARCHAR(255)), customers.other_customer_details (VARCHAR(255)), ) Table customers_cards ( customers_cards.card_id (INTEGER), customers_cards.customer_id (INTEGER), customers_cards.card_type_code (VARCHAR(15)), customers_cards.card_number (VARCHAR(80)), customers_cards.date_valid_from (DATETIME), customers_cards.date_valid_to (DATETIME), customers_cards.other_card_details (VARCHAR(255)), ) Table financial_transactions ( financial_transactions.transaction_id (INTEGER), financial_transactions.previous_transaction_id (INTEGER), financial_transactions.account_id (INTEGER), financial_transactions.card_id (INTEGER), financial_transactions.transaction_type (VARCHAR(15)), financial_transactions.transaction_date (DATETIME), financial_transactions.transaction_amount (DOUBLE), financial_transactions.transaction_comment (VARCHAR(255)), financial_transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: financial_transactions.account_id = accounts.account_id financial_transactions.card_id = customers_cards.card_id
{ 'accounts': ['account_id', 'customer_id', 'account_name', 'other_account_details'], 'customers': ['customer_id', 'customer_first_name', 'customer_last_name', 'customer_address', 'customer_phone', 'customer_email', 'other_customer_details'], 'customers_cards': ['card_id', 'customer_id', 'card_type_code', 'card_number', 'date_valid_from', 'date_valid_to', 'other_card_details'], 'financial_transactions': ['transaction_id', 'previous_transaction_id', 'account_id', 'card_id', 'transaction_type', 'transaction_date', 'transaction_amount', 'transaction_comment', 'other_transaction_details'] }
{ 'financial_transactions': ['account_id'] }
TABLE Financial_Transactions ( Financial_Transactions.account_id (INTEGER), )
TABLE Financial_Transactions ( Financial_Transactions.transaction_id (INTEGER), Financial_Transactions.previous_transaction_id (INTEGER), Financial_Transactions.account_id (INTEGER), Financial_Transactions.card_id (INTEGER), Financial_Transactions.transaction_type (VARCHAR(15)), Financial_Transactions.transaction_date (DATETIME), Financial_Transactions.transaction_amount (DOUBLE), Financial_Transactions.transaction_comment (VARCHAR(255)), Financial_Transactions.other_transaction_details (VARCHAR(255)), ) Possible JOINs: Financial_Transactions.account_id = Accounts.account_id Financial_Transactions.card_id = Customers_Cards.card_id
race_track
How many tracks do we have?
easy
Table race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) Table track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs: race.Track_ID = track.Track_ID
SELECT count(*) FROM track
Table race ( race.race_id (INT), race.name (TEXT), race.class (TEXT), race.date (TEXT), race.track_id (TEXT), ) Table track ( track.track_id (INT), track.name (TEXT), track.location (TEXT), track.seating (REAL), track.year_opened (REAL), ) Possible JOINs: race.track_id = track.track_id
{ 'race': ['race_id', 'name', 'class', 'date', 'track_id'], 'track': ['track_id', 'name', 'location', 'seating', 'year_opened'] }
{ 'track': ['track_id'] }
TABLE track ( track.Track_ID (INT), ) Possible JOINs:
TABLE track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs:
race_track
Count the number of tracks.
easy
Table race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) Table track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs: race.Track_ID = track.Track_ID
SELECT count(*) FROM track
Table race ( race.race_id (INT), race.name (TEXT), race.class (TEXT), race.date (TEXT), race.track_id (TEXT), ) Table track ( track.track_id (INT), track.name (TEXT), track.location (TEXT), track.seating (REAL), track.year_opened (REAL), ) Possible JOINs: race.track_id = track.track_id
{ 'race': ['race_id', 'name', 'class', 'date', 'track_id'], 'track': ['track_id', 'name', 'location', 'seating', 'year_opened'] }
{ 'track': ['track_id'] }
TABLE track ( track.Track_ID (INT), ) Possible JOINs:
TABLE track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs:
race_track
Show the name and location for all tracks.
medium
Table race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) Table track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs: race.Track_ID = track.Track_ID
SELECT name , LOCATION FROM track
Table race ( race.race_id (INT), race.name (TEXT), race.class (TEXT), race.date (TEXT), race.track_id (TEXT), ) Table track ( track.track_id (INT), track.name (TEXT), track.location (TEXT), track.seating (REAL), track.year_opened (REAL), ) Possible JOINs: race.track_id = track.track_id
{ 'race': ['race_id', 'name', 'class', 'date', 'track_id'], 'track': ['track_id', 'name', 'location', 'seating', 'year_opened'] }
{ 'track': ['track_id', 'name', 'location'] }
TABLE track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), ) Possible JOINs:
TABLE track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs:
race_track
What are the names and locations of all tracks?
medium
Table race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) Table track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs: race.Track_ID = track.Track_ID
SELECT name , LOCATION FROM track
Table race ( race.race_id (INT), race.name (TEXT), race.class (TEXT), race.date (TEXT), race.track_id (TEXT), ) Table track ( track.track_id (INT), track.name (TEXT), track.location (TEXT), track.seating (REAL), track.year_opened (REAL), ) Possible JOINs: race.track_id = track.track_id
{ 'race': ['race_id', 'name', 'class', 'date', 'track_id'], 'track': ['track_id', 'name', 'location', 'seating', 'year_opened'] }
{ 'track': ['track_id', 'name', 'location'] }
TABLE track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), ) Possible JOINs:
TABLE track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs:
race_track
Show names and seatings, ordered by seating for all tracks opened after 2000.
medium
Table race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) Table track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs: race.Track_ID = track.Track_ID
SELECT name , seating FROM track WHERE year_opened > 2000 ORDER BY seating
Table race ( race.race_id (INT), race.name (TEXT), race.class (TEXT), race.date (TEXT), race.track_id (TEXT), ) Table track ( track.track_id (INT), track.name (TEXT), track.location (TEXT), track.seating (REAL), track.year_opened (REAL), ) Possible JOINs: race.track_id = track.track_id
{ 'race': ['race_id', 'name', 'class', 'date', 'track_id'], 'track': ['track_id', 'name', 'location', 'seating', 'year_opened'] }
{ 'track': ['track_id', 'name', 'seating', 'year_opened'] }
TABLE track ( track.Track_ID (INT), track.Name (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs:
TABLE track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs:
race_track
What are the names and seatings for all tracks opened after 2000, ordered by seating?
medium
Table race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) Table track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs: race.Track_ID = track.Track_ID
SELECT name , seating FROM track WHERE year_opened > 2000 ORDER BY seating
Table race ( race.race_id (INT), race.name (TEXT), race.class (TEXT), race.date (TEXT), race.track_id (TEXT), ) Table track ( track.track_id (INT), track.name (TEXT), track.location (TEXT), track.seating (REAL), track.year_opened (REAL), ) Possible JOINs: race.track_id = track.track_id
{ 'race': ['race_id', 'name', 'class', 'date', 'track_id'], 'track': ['track_id', 'name', 'location', 'seating', 'year_opened'] }
{ 'track': ['track_id', 'name', 'seating', 'year_opened'] }
TABLE track ( track.Track_ID (INT), track.Name (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs:
TABLE track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs:
race_track
What is the name, location and seating for the most recently opened track?
medium
Table race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) Table track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs: race.Track_ID = track.Track_ID
SELECT name , LOCATION , seating FROM track ORDER BY year_opened DESC LIMIT 1
Table race ( race.race_id (INT), race.name (TEXT), race.class (TEXT), race.date (TEXT), race.track_id (TEXT), ) Table track ( track.track_id (INT), track.name (TEXT), track.location (TEXT), track.seating (REAL), track.year_opened (REAL), ) Possible JOINs: race.track_id = track.track_id
{ 'race': ['race_id', 'name', 'class', 'date', 'track_id'], 'track': ['track_id', 'name', 'location', 'seating', 'year_opened'] }
{ 'track': ['track_id', 'name', 'location', 'seating', 'year_opened'] }
TABLE track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs:
TABLE track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs:
race_track
Return the name, location, and seating of the track that was opened in the most recent year.
medium
Table race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) Table track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs: race.Track_ID = track.Track_ID
SELECT name , LOCATION , seating FROM track ORDER BY year_opened DESC LIMIT 1
Table race ( race.race_id (INT), race.name (TEXT), race.class (TEXT), race.date (TEXT), race.track_id (TEXT), ) Table track ( track.track_id (INT), track.name (TEXT), track.location (TEXT), track.seating (REAL), track.year_opened (REAL), ) Possible JOINs: race.track_id = track.track_id
{ 'race': ['race_id', 'name', 'class', 'date', 'track_id'], 'track': ['track_id', 'name', 'location', 'seating', 'year_opened'] }
{ 'track': ['track_id', 'name', 'location', 'seating', 'year_opened'] }
TABLE track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs:
TABLE track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs:
race_track
What is the minimum, maximum, and average seating for all tracks.
medium
Table race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) Table track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs: race.Track_ID = track.Track_ID
SELECT min(seating) , max(seating) , avg(seating) FROM track
Table race ( race.race_id (INT), race.name (TEXT), race.class (TEXT), race.date (TEXT), race.track_id (TEXT), ) Table track ( track.track_id (INT), track.name (TEXT), track.location (TEXT), track.seating (REAL), track.year_opened (REAL), ) Possible JOINs: race.track_id = track.track_id
{ 'race': ['race_id', 'name', 'class', 'date', 'track_id'], 'track': ['track_id', 'name', 'location', 'seating', 'year_opened'] }
{ 'track': ['track_id', 'seating'] }
TABLE track ( track.Track_ID (INT), track.Seating (REAL), ) Possible JOINs:
TABLE track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs:
race_track
Return the minimum, maximum, and average seating across all tracks.
medium
Table race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) Table track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs: race.Track_ID = track.Track_ID
SELECT min(seating) , max(seating) , avg(seating) FROM track
Table race ( race.race_id (INT), race.name (TEXT), race.class (TEXT), race.date (TEXT), race.track_id (TEXT), ) Table track ( track.track_id (INT), track.name (TEXT), track.location (TEXT), track.seating (REAL), track.year_opened (REAL), ) Possible JOINs: race.track_id = track.track_id
{ 'race': ['race_id', 'name', 'class', 'date', 'track_id'], 'track': ['track_id', 'name', 'location', 'seating', 'year_opened'] }
{ 'track': ['track_id', 'seating'] }
TABLE track ( track.Track_ID (INT), track.Seating (REAL), ) Possible JOINs:
TABLE track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs:
race_track
Show the name, location, open year for all tracks with a seating higher than the average.
extra
Table race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) Table track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs: race.Track_ID = track.Track_ID
SELECT name , LOCATION , year_opened FROM track WHERE seating > (SELECT avg(seating) FROM track)
Table race ( race.race_id (INT), race.name (TEXT), race.class (TEXT), race.date (TEXT), race.track_id (TEXT), ) Table track ( track.track_id (INT), track.name (TEXT), track.location (TEXT), track.seating (REAL), track.year_opened (REAL), ) Possible JOINs: race.track_id = track.track_id
{ 'race': ['race_id', 'name', 'class', 'date', 'track_id'], 'track': ['track_id', 'name', 'location', 'seating', 'year_opened'] }
{ 'track': ['track_id', 'name', 'location', 'seating', 'year_opened'] }
TABLE track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs:
TABLE track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs:
race_track
What are the names, locations, and years of opening for tracks with seating higher than average?
extra
Table race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) Table track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs: race.Track_ID = track.Track_ID
SELECT name , LOCATION , year_opened FROM track WHERE seating > (SELECT avg(seating) FROM track)
Table race ( race.race_id (INT), race.name (TEXT), race.class (TEXT), race.date (TEXT), race.track_id (TEXT), ) Table track ( track.track_id (INT), track.name (TEXT), track.location (TEXT), track.seating (REAL), track.year_opened (REAL), ) Possible JOINs: race.track_id = track.track_id
{ 'race': ['race_id', 'name', 'class', 'date', 'track_id'], 'track': ['track_id', 'name', 'location', 'seating', 'year_opened'] }
{ 'track': ['track_id', 'name', 'location', 'seating', 'year_opened'] }
TABLE track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs:
TABLE track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs:
race_track
What are distinct locations where tracks are located?
easy
Table race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) Table track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs: race.Track_ID = track.Track_ID
SELECT DISTINCT LOCATION FROM track
Table race ( race.race_id (INT), race.name (TEXT), race.class (TEXT), race.date (TEXT), race.track_id (TEXT), ) Table track ( track.track_id (INT), track.name (TEXT), track.location (TEXT), track.seating (REAL), track.year_opened (REAL), ) Possible JOINs: race.track_id = track.track_id
{ 'race': ['race_id', 'name', 'class', 'date', 'track_id'], 'track': ['track_id', 'name', 'location', 'seating', 'year_opened'] }
{ 'track': ['track_id', 'location'] }
TABLE track ( track.Track_ID (INT), track.Location (TEXT), ) Possible JOINs:
TABLE track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs:
race_track
Give the different locations of tracks.
easy
Table race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) Table track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs: race.Track_ID = track.Track_ID
SELECT DISTINCT LOCATION FROM track
Table race ( race.race_id (INT), race.name (TEXT), race.class (TEXT), race.date (TEXT), race.track_id (TEXT), ) Table track ( track.track_id (INT), track.name (TEXT), track.location (TEXT), track.seating (REAL), track.year_opened (REAL), ) Possible JOINs: race.track_id = track.track_id
{ 'race': ['race_id', 'name', 'class', 'date', 'track_id'], 'track': ['track_id', 'name', 'location', 'seating', 'year_opened'] }
{ 'track': ['track_id', 'location'] }
TABLE track ( track.Track_ID (INT), track.Location (TEXT), ) Possible JOINs:
TABLE track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs:
race_track
How many races are there?
easy
Table race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) Table track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs: race.Track_ID = track.Track_ID
SELECT count(*) FROM race
Table race ( race.race_id (INT), race.name (TEXT), race.class (TEXT), race.date (TEXT), race.track_id (TEXT), ) Table track ( track.track_id (INT), track.name (TEXT), track.location (TEXT), track.seating (REAL), track.year_opened (REAL), ) Possible JOINs: race.track_id = track.track_id
{ 'race': ['race_id', 'name', 'class', 'date', 'track_id'], 'track': ['track_id', 'name', 'location', 'seating', 'year_opened'] }
{ 'race': ['race_id'] }
TABLE race ( race.Race_ID (INT), )
TABLE race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) Possible JOINs: race.Track_ID = track.Track_ID
race_track
Count the number of races.
easy
Table race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) Table track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs: race.Track_ID = track.Track_ID
SELECT count(*) FROM race
Table race ( race.race_id (INT), race.name (TEXT), race.class (TEXT), race.date (TEXT), race.track_id (TEXT), ) Table track ( track.track_id (INT), track.name (TEXT), track.location (TEXT), track.seating (REAL), track.year_opened (REAL), ) Possible JOINs: race.track_id = track.track_id
{ 'race': ['race_id', 'name', 'class', 'date', 'track_id'], 'track': ['track_id', 'name', 'location', 'seating', 'year_opened'] }
{ 'race': ['race_id'] }
TABLE race ( race.Race_ID (INT), )
TABLE race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) Possible JOINs: race.Track_ID = track.Track_ID
race_track
What are the distinct classes that races can have?
easy
Table race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) Table track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs: race.Track_ID = track.Track_ID
SELECT DISTINCT CLASS FROM race
Table race ( race.race_id (INT), race.name (TEXT), race.class (TEXT), race.date (TEXT), race.track_id (TEXT), ) Table track ( track.track_id (INT), track.name (TEXT), track.location (TEXT), track.seating (REAL), track.year_opened (REAL), ) Possible JOINs: race.track_id = track.track_id
{ 'race': ['race_id', 'name', 'class', 'date', 'track_id'], 'track': ['track_id', 'name', 'location', 'seating', 'year_opened'] }
{ 'race': ['race_id', 'class'] }
TABLE race ( race.Race_ID (INT), race.Class (TEXT), )
TABLE race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) Possible JOINs: race.Track_ID = track.Track_ID
race_track
Return the different classes of races.
easy
Table race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) Table track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs: race.Track_ID = track.Track_ID
SELECT DISTINCT CLASS FROM race
Table race ( race.race_id (INT), race.name (TEXT), race.class (TEXT), race.date (TEXT), race.track_id (TEXT), ) Table track ( track.track_id (INT), track.name (TEXT), track.location (TEXT), track.seating (REAL), track.year_opened (REAL), ) Possible JOINs: race.track_id = track.track_id
{ 'race': ['race_id', 'name', 'class', 'date', 'track_id'], 'track': ['track_id', 'name', 'location', 'seating', 'year_opened'] }
{ 'race': ['race_id', 'class'] }
TABLE race ( race.Race_ID (INT), race.Class (TEXT), )
TABLE race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) Possible JOINs: race.Track_ID = track.Track_ID
race_track
Show name, class, and date for all races.
medium
Table race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) Table track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs: race.Track_ID = track.Track_ID
SELECT name , CLASS , date FROM race
Table race ( race.race_id (INT), race.name (TEXT), race.class (TEXT), race.date (TEXT), race.track_id (TEXT), ) Table track ( track.track_id (INT), track.name (TEXT), track.location (TEXT), track.seating (REAL), track.year_opened (REAL), ) Possible JOINs: race.track_id = track.track_id
{ 'race': ['race_id', 'name', 'class', 'date', 'track_id'], 'track': ['track_id', 'name', 'location', 'seating', 'year_opened'] }
{ 'race': ['race_id', 'name', 'class', 'date'] }
TABLE race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), )
TABLE race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) Possible JOINs: race.Track_ID = track.Track_ID
race_track
What are the names, classes, and dates for all races?
medium
Table race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) Table track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs: race.Track_ID = track.Track_ID
SELECT name , CLASS , date FROM race
Table race ( race.race_id (INT), race.name (TEXT), race.class (TEXT), race.date (TEXT), race.track_id (TEXT), ) Table track ( track.track_id (INT), track.name (TEXT), track.location (TEXT), track.seating (REAL), track.year_opened (REAL), ) Possible JOINs: race.track_id = track.track_id
{ 'race': ['race_id', 'name', 'class', 'date', 'track_id'], 'track': ['track_id', 'name', 'location', 'seating', 'year_opened'] }
{ 'race': ['race_id', 'name', 'class', 'date'] }
TABLE race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), )
TABLE race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) Possible JOINs: race.Track_ID = track.Track_ID
race_track
Show the race class and number of races in each class.
medium
Table race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) Table track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs: race.Track_ID = track.Track_ID
SELECT CLASS , count(*) FROM race GROUP BY CLASS
Table race ( race.race_id (INT), race.name (TEXT), race.class (TEXT), race.date (TEXT), race.track_id (TEXT), ) Table track ( track.track_id (INT), track.name (TEXT), track.location (TEXT), track.seating (REAL), track.year_opened (REAL), ) Possible JOINs: race.track_id = track.track_id
{ 'race': ['race_id', 'name', 'class', 'date', 'track_id'], 'track': ['track_id', 'name', 'location', 'seating', 'year_opened'] }
{ 'race': ['race_id', 'class'] }
TABLE race ( race.Race_ID (INT), race.Class (TEXT), )
TABLE race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) Possible JOINs: race.Track_ID = track.Track_ID
race_track
What are the different classes of races, and how many races correspond to each?
medium
Table race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) Table track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs: race.Track_ID = track.Track_ID
SELECT CLASS , count(*) FROM race GROUP BY CLASS
Table race ( race.race_id (INT), race.name (TEXT), race.class (TEXT), race.date (TEXT), race.track_id (TEXT), ) Table track ( track.track_id (INT), track.name (TEXT), track.location (TEXT), track.seating (REAL), track.year_opened (REAL), ) Possible JOINs: race.track_id = track.track_id
{ 'race': ['race_id', 'name', 'class', 'date', 'track_id'], 'track': ['track_id', 'name', 'location', 'seating', 'year_opened'] }
{ 'race': ['race_id', 'class'] }
TABLE race ( race.Race_ID (INT), race.Class (TEXT), )
TABLE race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) Possible JOINs: race.Track_ID = track.Track_ID
race_track
What is the race class with most number of races.
hard
Table race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) Table track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs: race.Track_ID = track.Track_ID
SELECT CLASS FROM race GROUP BY CLASS ORDER BY count(*) DESC LIMIT 1
Table race ( race.race_id (INT), race.name (TEXT), race.class (TEXT), race.date (TEXT), race.track_id (TEXT), ) Table track ( track.track_id (INT), track.name (TEXT), track.location (TEXT), track.seating (REAL), track.year_opened (REAL), ) Possible JOINs: race.track_id = track.track_id
{ 'race': ['race_id', 'name', 'class', 'date', 'track_id'], 'track': ['track_id', 'name', 'location', 'seating', 'year_opened'] }
{ 'race': ['race_id', 'class'] }
TABLE race ( race.Race_ID (INT), race.Class (TEXT), )
TABLE race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) Possible JOINs: race.Track_ID = track.Track_ID
race_track
Give the class of races that is most common.
hard
Table race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) Table track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs: race.Track_ID = track.Track_ID
SELECT CLASS FROM race GROUP BY CLASS ORDER BY count(*) DESC LIMIT 1
Table race ( race.race_id (INT), race.name (TEXT), race.class (TEXT), race.date (TEXT), race.track_id (TEXT), ) Table track ( track.track_id (INT), track.name (TEXT), track.location (TEXT), track.seating (REAL), track.year_opened (REAL), ) Possible JOINs: race.track_id = track.track_id
{ 'race': ['race_id', 'name', 'class', 'date', 'track_id'], 'track': ['track_id', 'name', 'location', 'seating', 'year_opened'] }
{ 'race': ['race_id', 'class'] }
TABLE race ( race.Race_ID (INT), race.Class (TEXT), )
TABLE race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) Possible JOINs: race.Track_ID = track.Track_ID
race_track
List the race class with at least two races.
easy
Table race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) Table track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs: race.Track_ID = track.Track_ID
SELECT CLASS FROM race GROUP BY CLASS HAVING count(*) >= 2
Table race ( race.race_id (INT), race.name (TEXT), race.class (TEXT), race.date (TEXT), race.track_id (TEXT), ) Table track ( track.track_id (INT), track.name (TEXT), track.location (TEXT), track.seating (REAL), track.year_opened (REAL), ) Possible JOINs: race.track_id = track.track_id
{ 'race': ['race_id', 'name', 'class', 'date', 'track_id'], 'track': ['track_id', 'name', 'location', 'seating', 'year_opened'] }
{ 'race': ['race_id', 'class'] }
TABLE race ( race.Race_ID (INT), race.Class (TEXT), )
TABLE race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) Possible JOINs: race.Track_ID = track.Track_ID
race_track
What are the classes of races that have two or more corresponding races?
easy
Table race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) Table track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs: race.Track_ID = track.Track_ID
SELECT CLASS FROM race GROUP BY CLASS HAVING count(*) >= 2
Table race ( race.race_id (INT), race.name (TEXT), race.class (TEXT), race.date (TEXT), race.track_id (TEXT), ) Table track ( track.track_id (INT), track.name (TEXT), track.location (TEXT), track.seating (REAL), track.year_opened (REAL), ) Possible JOINs: race.track_id = track.track_id
{ 'race': ['race_id', 'name', 'class', 'date', 'track_id'], 'track': ['track_id', 'name', 'location', 'seating', 'year_opened'] }
{ 'race': ['race_id', 'class'] }
TABLE race ( race.Race_ID (INT), race.Class (TEXT), )
TABLE race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) Possible JOINs: race.Track_ID = track.Track_ID
race_track
What are the names for tracks without a race in class 'GT'.
hard
Table race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) Table track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs: race.Track_ID = track.Track_ID
SELECT name FROM track EXCEPT SELECT track.name FROM race JOIN track ON race.track_id = track.track_id WHERE race.class = 'GT'
Table race ( race.race_id (INT), race.name (TEXT), race.class (TEXT), race.date (TEXT), race.track_id (TEXT), ) Table track ( track.track_id (INT), track.name (TEXT), track.location (TEXT), track.seating (REAL), track.year_opened (REAL), ) Possible JOINs: race.track_id = track.track_id
{ 'race': ['race_id', 'name', 'class', 'date', 'track_id'], 'track': ['track_id', 'name', 'location', 'seating', 'year_opened'] }
{ 'track': ['track_id', 'name'], 'race': ['race_id', 'name', 'class', 'track_id'] }
TABLE race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Track_ID (TEXT), ) TABLE track ( track.Track_ID (INT), track.Name (TEXT), )
TABLE race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) TABLE track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs: race.Track_ID = track.Track_ID
race_track
Give the names of tracks that do not have a race in the class 'GT'.
hard
Table race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) Table track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs: race.Track_ID = track.Track_ID
SELECT name FROM track EXCEPT SELECT track.name FROM race JOIN track ON race.track_id = track.track_id WHERE race.class = 'GT'
Table race ( race.race_id (INT), race.name (TEXT), race.class (TEXT), race.date (TEXT), race.track_id (TEXT), ) Table track ( track.track_id (INT), track.name (TEXT), track.location (TEXT), track.seating (REAL), track.year_opened (REAL), ) Possible JOINs: race.track_id = track.track_id
{ 'race': ['race_id', 'name', 'class', 'date', 'track_id'], 'track': ['track_id', 'name', 'location', 'seating', 'year_opened'] }
{ 'track': ['track_id', 'name'], 'race': ['race_id', 'name', 'class', 'track_id'] }
TABLE race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Track_ID (TEXT), ) TABLE track ( track.Track_ID (INT), track.Name (TEXT), )
TABLE race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) TABLE track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs: race.Track_ID = track.Track_ID
race_track
Show all track names that have had no races.
hard
Table race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) Table track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs: race.Track_ID = track.Track_ID
SELECT name FROM track WHERE track_id NOT IN (SELECT track_id FROM race)
Table race ( race.race_id (INT), race.name (TEXT), race.class (TEXT), race.date (TEXT), race.track_id (TEXT), ) Table track ( track.track_id (INT), track.name (TEXT), track.location (TEXT), track.seating (REAL), track.year_opened (REAL), ) Possible JOINs: race.track_id = track.track_id
{ 'race': ['race_id', 'name', 'class', 'date', 'track_id'], 'track': ['track_id', 'name', 'location', 'seating', 'year_opened'] }
{ 'track': ['track_id', 'name'], 'race': ['race_id', 'name', 'track_id'] }
TABLE race ( race.Race_ID (INT), race.Name (TEXT), race.Track_ID (TEXT), ) TABLE track ( track.Track_ID (INT), track.Name (TEXT), )
TABLE race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) TABLE track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs: race.Track_ID = track.Track_ID
race_track
Return the names of tracks that have no had any races.
hard
Table race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) Table track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs: race.Track_ID = track.Track_ID
SELECT name FROM track WHERE track_id NOT IN (SELECT track_id FROM race)
Table race ( race.race_id (INT), race.name (TEXT), race.class (TEXT), race.date (TEXT), race.track_id (TEXT), ) Table track ( track.track_id (INT), track.name (TEXT), track.location (TEXT), track.seating (REAL), track.year_opened (REAL), ) Possible JOINs: race.track_id = track.track_id
{ 'race': ['race_id', 'name', 'class', 'date', 'track_id'], 'track': ['track_id', 'name', 'location', 'seating', 'year_opened'] }
{ 'track': ['track_id', 'name'], 'race': ['race_id', 'name', 'track_id'] }
TABLE race ( race.Race_ID (INT), race.Name (TEXT), race.Track_ID (TEXT), ) TABLE track ( track.Track_ID (INT), track.Name (TEXT), )
TABLE race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) TABLE track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs: race.Track_ID = track.Track_ID
race_track
Show year where a track with a seating at least 5000 opened and a track with seating no more than 4000 opened.
easy
Table race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) Table track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs: race.Track_ID = track.Track_ID
SELECT year_opened FROM track WHERE seating BETWEEN 4000 AND 5000
Table race ( race.race_id (INT), race.name (TEXT), race.class (TEXT), race.date (TEXT), race.track_id (TEXT), ) Table track ( track.track_id (INT), track.name (TEXT), track.location (TEXT), track.seating (REAL), track.year_opened (REAL), ) Possible JOINs: race.track_id = track.track_id
{ 'race': ['race_id', 'name', 'class', 'date', 'track_id'], 'track': ['track_id', 'name', 'location', 'seating', 'year_opened'] }
{ 'track': ['track_id', 'seating', 'year_opened'] }
TABLE track ( track.Track_ID (INT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs:
TABLE track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs:
race_track
What are the years of opening for tracks with seating between 4000 and 5000?
easy
Table race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) Table track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs: race.Track_ID = track.Track_ID
SELECT year_opened FROM track WHERE seating BETWEEN 4000 AND 5000
Table race ( race.race_id (INT), race.name (TEXT), race.class (TEXT), race.date (TEXT), race.track_id (TEXT), ) Table track ( track.track_id (INT), track.name (TEXT), track.location (TEXT), track.seating (REAL), track.year_opened (REAL), ) Possible JOINs: race.track_id = track.track_id
{ 'race': ['race_id', 'name', 'class', 'date', 'track_id'], 'track': ['track_id', 'name', 'location', 'seating', 'year_opened'] }
{ 'track': ['track_id', 'seating', 'year_opened'] }
TABLE track ( track.Track_ID (INT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs:
TABLE track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs:
race_track
Show the name of track and the number of races in each track.
medium
Table race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) Table track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs: race.Track_ID = track.Track_ID
SELECT track.name , count(*) FROM race JOIN track ON race.track_id = track.track_id GROUP BY race.track_id
Table race ( race.race_id (INT), race.name (TEXT), race.class (TEXT), race.date (TEXT), race.track_id (TEXT), ) Table track ( track.track_id (INT), track.name (TEXT), track.location (TEXT), track.seating (REAL), track.year_opened (REAL), ) Possible JOINs: race.track_id = track.track_id
{ 'race': ['race_id', 'name', 'class', 'date', 'track_id'], 'track': ['track_id', 'name', 'location', 'seating', 'year_opened'] }
{ 'race': ['race_id', 'track_id'], 'track': ['track_id', 'name'] }
TABLE race ( race.Race_ID (INT), race.Track_ID (TEXT), ) TABLE track ( track.Track_ID (INT), track.Name (TEXT), )
TABLE race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) TABLE track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs: race.Track_ID = track.Track_ID
race_track
What are the names of different tracks, and how many races has each had?
medium
Table race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) Table track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs: race.Track_ID = track.Track_ID
SELECT track.name , count(*) FROM race JOIN track ON race.track_id = track.track_id GROUP BY race.track_id
Table race ( race.race_id (INT), race.name (TEXT), race.class (TEXT), race.date (TEXT), race.track_id (TEXT), ) Table track ( track.track_id (INT), track.name (TEXT), track.location (TEXT), track.seating (REAL), track.year_opened (REAL), ) Possible JOINs: race.track_id = track.track_id
{ 'race': ['race_id', 'name', 'class', 'date', 'track_id'], 'track': ['track_id', 'name', 'location', 'seating', 'year_opened'] }
{ 'race': ['race_id', 'track_id'], 'track': ['track_id', 'name'] }
TABLE race ( race.Race_ID (INT), race.Track_ID (TEXT), ) TABLE track ( track.Track_ID (INT), track.Name (TEXT), )
TABLE race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) TABLE track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs: race.Track_ID = track.Track_ID
race_track
Show the name of track with most number of races.
extra
Table race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) Table track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs: race.Track_ID = track.Track_ID
SELECT track.name FROM race JOIN track ON race.track_id = track.track_id GROUP BY race.track_id ORDER BY count(*) DESC LIMIT 1
Table race ( race.race_id (INT), race.name (TEXT), race.class (TEXT), race.date (TEXT), race.track_id (TEXT), ) Table track ( track.track_id (INT), track.name (TEXT), track.location (TEXT), track.seating (REAL), track.year_opened (REAL), ) Possible JOINs: race.track_id = track.track_id
{ 'race': ['race_id', 'name', 'class', 'date', 'track_id'], 'track': ['track_id', 'name', 'location', 'seating', 'year_opened'] }
{ 'race': ['race_id', 'track_id'], 'track': ['track_id', 'name'] }
TABLE race ( race.Race_ID (INT), race.Track_ID (TEXT), ) TABLE track ( track.Track_ID (INT), track.Name (TEXT), )
TABLE race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) TABLE track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs: race.Track_ID = track.Track_ID
race_track
What is the name of the track that has had the greatest number of races?
extra
Table race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) Table track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs: race.Track_ID = track.Track_ID
SELECT track.name FROM race JOIN track ON race.track_id = track.track_id GROUP BY race.track_id ORDER BY count(*) DESC LIMIT 1
Table race ( race.race_id (INT), race.name (TEXT), race.class (TEXT), race.date (TEXT), race.track_id (TEXT), ) Table track ( track.track_id (INT), track.name (TEXT), track.location (TEXT), track.seating (REAL), track.year_opened (REAL), ) Possible JOINs: race.track_id = track.track_id
{ 'race': ['race_id', 'name', 'class', 'date', 'track_id'], 'track': ['track_id', 'name', 'location', 'seating', 'year_opened'] }
{ 'race': ['race_id', 'track_id'], 'track': ['track_id', 'name'] }
TABLE race ( race.Race_ID (INT), race.Track_ID (TEXT), ) TABLE track ( track.Track_ID (INT), track.Name (TEXT), )
TABLE race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) TABLE track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs: race.Track_ID = track.Track_ID
race_track
Show the name and date for each race and its track name.
medium
Table race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) Table track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs: race.Track_ID = track.Track_ID
SELECT race.name , race.date , track.name FROM race JOIN track ON race.track_id = track.track_id
Table race ( race.race_id (INT), race.name (TEXT), race.class (TEXT), race.date (TEXT), race.track_id (TEXT), ) Table track ( track.track_id (INT), track.name (TEXT), track.location (TEXT), track.seating (REAL), track.year_opened (REAL), ) Possible JOINs: race.track_id = track.track_id
{ 'race': ['race_id', 'name', 'class', 'date', 'track_id'], 'track': ['track_id', 'name', 'location', 'seating', 'year_opened'] }
{ 'race': ['race_id', 'name', 'date', 'track_id'], 'track': ['track_id', 'name'] }
TABLE race ( race.Race_ID (INT), race.Name (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) TABLE track ( track.Track_ID (INT), track.Name (TEXT), )
TABLE race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) TABLE track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs: race.Track_ID = track.Track_ID
race_track
What are the names and dates of races, and the names of the tracks where they are held?
medium
Table race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) Table track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs: race.Track_ID = track.Track_ID
SELECT race.name , race.date , track.name FROM race JOIN track ON race.track_id = track.track_id
Table race ( race.race_id (INT), race.name (TEXT), race.class (TEXT), race.date (TEXT), race.track_id (TEXT), ) Table track ( track.track_id (INT), track.name (TEXT), track.location (TEXT), track.seating (REAL), track.year_opened (REAL), ) Possible JOINs: race.track_id = track.track_id
{ 'race': ['race_id', 'name', 'class', 'date', 'track_id'], 'track': ['track_id', 'name', 'location', 'seating', 'year_opened'] }
{ 'race': ['race_id', 'name', 'date', 'track_id'], 'track': ['track_id', 'name'] }
TABLE race ( race.Race_ID (INT), race.Name (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) TABLE track ( track.Track_ID (INT), track.Name (TEXT), )
TABLE race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) TABLE track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs: race.Track_ID = track.Track_ID
race_track
Show the name and location of track with 1 race.
medium
Table race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) Table track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs: race.Track_ID = track.Track_ID
SELECT track.name , track.location FROM race JOIN track ON race.track_id = track.track_id GROUP BY race.track_id HAVING count(*) = 1
Table race ( race.race_id (INT), race.name (TEXT), race.class (TEXT), race.date (TEXT), race.track_id (TEXT), ) Table track ( track.track_id (INT), track.name (TEXT), track.location (TEXT), track.seating (REAL), track.year_opened (REAL), ) Possible JOINs: race.track_id = track.track_id
{ 'race': ['race_id', 'name', 'class', 'date', 'track_id'], 'track': ['track_id', 'name', 'location', 'seating', 'year_opened'] }
{ 'race': ['race_id', 'track_id'], 'track': ['track_id', 'name', 'location'] }
TABLE race ( race.Race_ID (INT), race.Track_ID (TEXT), ) TABLE track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), )
TABLE race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) TABLE track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs: race.Track_ID = track.Track_ID
race_track
What are the names and locations of tracks that have had exactly 1 race?
medium
Table race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) Table track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs: race.Track_ID = track.Track_ID
SELECT track.name , track.location FROM race JOIN track ON race.track_id = track.track_id GROUP BY race.track_id HAVING count(*) = 1
Table race ( race.race_id (INT), race.name (TEXT), race.class (TEXT), race.date (TEXT), race.track_id (TEXT), ) Table track ( track.track_id (INT), track.name (TEXT), track.location (TEXT), track.seating (REAL), track.year_opened (REAL), ) Possible JOINs: race.track_id = track.track_id
{ 'race': ['race_id', 'name', 'class', 'date', 'track_id'], 'track': ['track_id', 'name', 'location', 'seating', 'year_opened'] }
{ 'race': ['race_id', 'track_id'], 'track': ['track_id', 'name', 'location'] }
TABLE race ( race.Race_ID (INT), race.Track_ID (TEXT), ) TABLE track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), )
TABLE race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) TABLE track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs: race.Track_ID = track.Track_ID
race_track
Find the locations where have both tracks with more than 90000 seats and tracks with less than 70000 seats.
hard
Table race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) Table track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs: race.Track_ID = track.Track_ID
SELECT LOCATION FROM track WHERE seating > 90000 INTERSECT SELECT LOCATION FROM track WHERE seating < 70000
Table race ( race.race_id (INT), race.name (TEXT), race.class (TEXT), race.date (TEXT), race.track_id (TEXT), ) Table track ( track.track_id (INT), track.name (TEXT), track.location (TEXT), track.seating (REAL), track.year_opened (REAL), ) Possible JOINs: race.track_id = track.track_id
{ 'race': ['race_id', 'name', 'class', 'date', 'track_id'], 'track': ['track_id', 'name', 'location', 'seating', 'year_opened'] }
{ 'track': ['track_id', 'location', 'seating'] }
TABLE track ( track.Track_ID (INT), track.Location (TEXT), track.Seating (REAL), ) Possible JOINs:
TABLE track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs:
race_track
What are the locations that have both tracks with more than 90000 seats, and tracks with fewer than 70000 seats?
hard
Table race ( race.Race_ID (INT), race.Name (TEXT), race.Class (TEXT), race.Date (TEXT), race.Track_ID (TEXT), ) Table track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs: race.Track_ID = track.Track_ID
SELECT LOCATION FROM track WHERE seating > 90000 INTERSECT SELECT LOCATION FROM track WHERE seating < 70000
Table race ( race.race_id (INT), race.name (TEXT), race.class (TEXT), race.date (TEXT), race.track_id (TEXT), ) Table track ( track.track_id (INT), track.name (TEXT), track.location (TEXT), track.seating (REAL), track.year_opened (REAL), ) Possible JOINs: race.track_id = track.track_id
{ 'race': ['race_id', 'name', 'class', 'date', 'track_id'], 'track': ['track_id', 'name', 'location', 'seating', 'year_opened'] }
{ 'track': ['track_id', 'location', 'seating'] }
TABLE track ( track.Track_ID (INT), track.Location (TEXT), track.Seating (REAL), ) Possible JOINs:
TABLE track ( track.Track_ID (INT), track.Name (TEXT), track.Location (TEXT), track.Seating (REAL), track.Year_Opened (REAL), ) Possible JOINs:
coffee_shop
How many members have the black membership card?
easy
Table happy_hour ( happy_hour.HH_ID (INT), happy_hour.Shop_ID (INT), happy_hour.Month (TEXT), happy_hour.Num_of_shaff_in_charge (INT), ) Table happy_hour_member ( happy_hour_member.HH_ID (INT), happy_hour_member.Member_ID (INT), happy_hour_member.Total_amount (REAL), ) Table member ( member.Member_ID (INT), member.Name (TEXT), member.Membership_card (TEXT), member.Age (INT), member.Time_of_purchase (INT), member.Level_of_membership (INT), member.Address (TEXT), ) Table shop ( shop.Shop_ID (INT), shop.Address (TEXT), shop.Num_of_staff (TEXT), shop.Score (REAL), shop.Open_Year (TEXT), ) Possible JOINs: happy_hour.Shop_ID = shop.Shop_ID happy_hour_member.Member_ID = member.Member_ID
SELECT count(*) FROM member WHERE Membership_card = 'Black'
Table happy_hour ( happy_hour.hh_id (INT), happy_hour.shop_id (INT), happy_hour.month (TEXT), happy_hour.num_of_shaff_in_charge (INT), ) Table happy_hour_member ( happy_hour_member.hh_id (INT), happy_hour_member.member_id (INT), happy_hour_member.total_amount (REAL), ) Table member ( member.member_id (INT), member.name (TEXT), member.membership_card (TEXT), member.age (INT), member.time_of_purchase (INT), member.level_of_membership (INT), member.address (TEXT), ) Table shop ( shop.shop_id (INT), shop.address (TEXT), shop.num_of_staff (TEXT), shop.score (REAL), shop.open_year (TEXT), ) Possible JOINs: happy_hour.shop_id = shop.shop_id happy_hour_member.member_id = member.member_id
{ 'shop': ['shop_id', 'address', 'num_of_staff', 'score', 'open_year'], 'member': ['member_id', 'name', 'membership_card', 'age', 'time_of_purchase', 'level_of_membership', 'address'], 'happy_hour': ['hh_id', 'shop_id', 'month', 'num_of_shaff_in_charge'], 'happy_hour_member': ['hh_id', 'member_id', 'total_amount'] }
{ 'member': ['member_id', 'membership_card'] }
TABLE member ( member.Member_ID (INT), member.Membership_card (TEXT), ) Possible JOINs:
TABLE member ( member.Member_ID (INT), member.Name (TEXT), member.Membership_card (TEXT), member.Age (INT), member.Time_of_purchase (INT), member.Level_of_membership (INT), member.Address (TEXT), ) Possible JOINs:
coffee_shop
Find the number of members living in each address.
medium
Table happy_hour ( happy_hour.HH_ID (INT), happy_hour.Shop_ID (INT), happy_hour.Month (TEXT), happy_hour.Num_of_shaff_in_charge (INT), ) Table happy_hour_member ( happy_hour_member.HH_ID (INT), happy_hour_member.Member_ID (INT), happy_hour_member.Total_amount (REAL), ) Table member ( member.Member_ID (INT), member.Name (TEXT), member.Membership_card (TEXT), member.Age (INT), member.Time_of_purchase (INT), member.Level_of_membership (INT), member.Address (TEXT), ) Table shop ( shop.Shop_ID (INT), shop.Address (TEXT), shop.Num_of_staff (TEXT), shop.Score (REAL), shop.Open_Year (TEXT), ) Possible JOINs: happy_hour.Shop_ID = shop.Shop_ID happy_hour_member.Member_ID = member.Member_ID
SELECT count(*) , address FROM member GROUP BY address
Table happy_hour ( happy_hour.hh_id (INT), happy_hour.shop_id (INT), happy_hour.month (TEXT), happy_hour.num_of_shaff_in_charge (INT), ) Table happy_hour_member ( happy_hour_member.hh_id (INT), happy_hour_member.member_id (INT), happy_hour_member.total_amount (REAL), ) Table member ( member.member_id (INT), member.name (TEXT), member.membership_card (TEXT), member.age (INT), member.time_of_purchase (INT), member.level_of_membership (INT), member.address (TEXT), ) Table shop ( shop.shop_id (INT), shop.address (TEXT), shop.num_of_staff (TEXT), shop.score (REAL), shop.open_year (TEXT), ) Possible JOINs: happy_hour.shop_id = shop.shop_id happy_hour_member.member_id = member.member_id
{ 'shop': ['shop_id', 'address', 'num_of_staff', 'score', 'open_year'], 'member': ['member_id', 'name', 'membership_card', 'age', 'time_of_purchase', 'level_of_membership', 'address'], 'happy_hour': ['hh_id', 'shop_id', 'month', 'num_of_shaff_in_charge'], 'happy_hour_member': ['hh_id', 'member_id', 'total_amount'] }
{ 'member': ['member_id', 'address'] }
TABLE member ( member.Member_ID (INT), member.Address (TEXT), ) Possible JOINs:
TABLE member ( member.Member_ID (INT), member.Name (TEXT), member.Membership_card (TEXT), member.Age (INT), member.Time_of_purchase (INT), member.Level_of_membership (INT), member.Address (TEXT), ) Possible JOINs:
coffee_shop
Give me the names of members whose address is in Harford or Waterbury.
medium
Table happy_hour ( happy_hour.HH_ID (INT), happy_hour.Shop_ID (INT), happy_hour.Month (TEXT), happy_hour.Num_of_shaff_in_charge (INT), ) Table happy_hour_member ( happy_hour_member.HH_ID (INT), happy_hour_member.Member_ID (INT), happy_hour_member.Total_amount (REAL), ) Table member ( member.Member_ID (INT), member.Name (TEXT), member.Membership_card (TEXT), member.Age (INT), member.Time_of_purchase (INT), member.Level_of_membership (INT), member.Address (TEXT), ) Table shop ( shop.Shop_ID (INT), shop.Address (TEXT), shop.Num_of_staff (TEXT), shop.Score (REAL), shop.Open_Year (TEXT), ) Possible JOINs: happy_hour.Shop_ID = shop.Shop_ID happy_hour_member.Member_ID = member.Member_ID
SELECT name FROM member WHERE address = 'Harford' OR address = 'Waterbury'
Table happy_hour ( happy_hour.hh_id (INT), happy_hour.shop_id (INT), happy_hour.month (TEXT), happy_hour.num_of_shaff_in_charge (INT), ) Table happy_hour_member ( happy_hour_member.hh_id (INT), happy_hour_member.member_id (INT), happy_hour_member.total_amount (REAL), ) Table member ( member.member_id (INT), member.name (TEXT), member.membership_card (TEXT), member.age (INT), member.time_of_purchase (INT), member.level_of_membership (INT), member.address (TEXT), ) Table shop ( shop.shop_id (INT), shop.address (TEXT), shop.num_of_staff (TEXT), shop.score (REAL), shop.open_year (TEXT), ) Possible JOINs: happy_hour.shop_id = shop.shop_id happy_hour_member.member_id = member.member_id
{ 'shop': ['shop_id', 'address', 'num_of_staff', 'score', 'open_year'], 'member': ['member_id', 'name', 'membership_card', 'age', 'time_of_purchase', 'level_of_membership', 'address'], 'happy_hour': ['hh_id', 'shop_id', 'month', 'num_of_shaff_in_charge'], 'happy_hour_member': ['hh_id', 'member_id', 'total_amount'] }
{ 'member': ['member_id', 'name', 'address'] }
TABLE member ( member.Member_ID (INT), member.Name (TEXT), member.Address (TEXT), ) Possible JOINs:
TABLE member ( member.Member_ID (INT), member.Name (TEXT), member.Membership_card (TEXT), member.Age (INT), member.Time_of_purchase (INT), member.Level_of_membership (INT), member.Address (TEXT), ) Possible JOINs:
coffee_shop
Find the ids and names of members who are under age 30 or with black membership card.
extra
Table happy_hour ( happy_hour.HH_ID (INT), happy_hour.Shop_ID (INT), happy_hour.Month (TEXT), happy_hour.Num_of_shaff_in_charge (INT), ) Table happy_hour_member ( happy_hour_member.HH_ID (INT), happy_hour_member.Member_ID (INT), happy_hour_member.Total_amount (REAL), ) Table member ( member.Member_ID (INT), member.Name (TEXT), member.Membership_card (TEXT), member.Age (INT), member.Time_of_purchase (INT), member.Level_of_membership (INT), member.Address (TEXT), ) Table shop ( shop.Shop_ID (INT), shop.Address (TEXT), shop.Num_of_staff (TEXT), shop.Score (REAL), shop.Open_Year (TEXT), ) Possible JOINs: happy_hour.Shop_ID = shop.Shop_ID happy_hour_member.Member_ID = member.Member_ID
SELECT name , member_id FROM member WHERE Membership_card = 'Black' OR age < 30
Table happy_hour ( happy_hour.hh_id (INT), happy_hour.shop_id (INT), happy_hour.month (TEXT), happy_hour.num_of_shaff_in_charge (INT), ) Table happy_hour_member ( happy_hour_member.hh_id (INT), happy_hour_member.member_id (INT), happy_hour_member.total_amount (REAL), ) Table member ( member.member_id (INT), member.name (TEXT), member.membership_card (TEXT), member.age (INT), member.time_of_purchase (INT), member.level_of_membership (INT), member.address (TEXT), ) Table shop ( shop.shop_id (INT), shop.address (TEXT), shop.num_of_staff (TEXT), shop.score (REAL), shop.open_year (TEXT), ) Possible JOINs: happy_hour.shop_id = shop.shop_id happy_hour_member.member_id = member.member_id
{ 'shop': ['shop_id', 'address', 'num_of_staff', 'score', 'open_year'], 'member': ['member_id', 'name', 'membership_card', 'age', 'time_of_purchase', 'level_of_membership', 'address'], 'happy_hour': ['hh_id', 'shop_id', 'month', 'num_of_shaff_in_charge'], 'happy_hour_member': ['hh_id', 'member_id', 'total_amount'] }
{ 'member': ['member_id', 'name', 'membership_card', 'age'] }
TABLE member ( member.Member_ID (INT), member.Name (TEXT), member.Membership_card (TEXT), member.Age (INT), ) Possible JOINs:
TABLE member ( member.Member_ID (INT), member.Name (TEXT), member.Membership_card (TEXT), member.Age (INT), member.Time_of_purchase (INT), member.Level_of_membership (INT), member.Address (TEXT), ) Possible JOINs:
coffee_shop
Find the purchase time, age and address of each member, and show the results in the order of purchase time.
medium
Table happy_hour ( happy_hour.HH_ID (INT), happy_hour.Shop_ID (INT), happy_hour.Month (TEXT), happy_hour.Num_of_shaff_in_charge (INT), ) Table happy_hour_member ( happy_hour_member.HH_ID (INT), happy_hour_member.Member_ID (INT), happy_hour_member.Total_amount (REAL), ) Table member ( member.Member_ID (INT), member.Name (TEXT), member.Membership_card (TEXT), member.Age (INT), member.Time_of_purchase (INT), member.Level_of_membership (INT), member.Address (TEXT), ) Table shop ( shop.Shop_ID (INT), shop.Address (TEXT), shop.Num_of_staff (TEXT), shop.Score (REAL), shop.Open_Year (TEXT), ) Possible JOINs: happy_hour.Shop_ID = shop.Shop_ID happy_hour_member.Member_ID = member.Member_ID
SELECT Time_of_purchase , age , address FROM member ORDER BY Time_of_purchase
Table happy_hour ( happy_hour.hh_id (INT), happy_hour.shop_id (INT), happy_hour.month (TEXT), happy_hour.num_of_shaff_in_charge (INT), ) Table happy_hour_member ( happy_hour_member.hh_id (INT), happy_hour_member.member_id (INT), happy_hour_member.total_amount (REAL), ) Table member ( member.member_id (INT), member.name (TEXT), member.membership_card (TEXT), member.age (INT), member.time_of_purchase (INT), member.level_of_membership (INT), member.address (TEXT), ) Table shop ( shop.shop_id (INT), shop.address (TEXT), shop.num_of_staff (TEXT), shop.score (REAL), shop.open_year (TEXT), ) Possible JOINs: happy_hour.shop_id = shop.shop_id happy_hour_member.member_id = member.member_id
{ 'shop': ['shop_id', 'address', 'num_of_staff', 'score', 'open_year'], 'member': ['member_id', 'name', 'membership_card', 'age', 'time_of_purchase', 'level_of_membership', 'address'], 'happy_hour': ['hh_id', 'shop_id', 'month', 'num_of_shaff_in_charge'], 'happy_hour_member': ['hh_id', 'member_id', 'total_amount'] }
{ 'member': ['member_id', 'age', 'time_of_purchase', 'address'] }
TABLE member ( member.Member_ID (INT), member.Age (INT), member.Time_of_purchase (INT), member.Address (TEXT), ) Possible JOINs:
TABLE member ( member.Member_ID (INT), member.Name (TEXT), member.Membership_card (TEXT), member.Age (INT), member.Time_of_purchase (INT), member.Level_of_membership (INT), member.Address (TEXT), ) Possible JOINs:
coffee_shop
Which membership card has more than 5 members?
easy
Table happy_hour ( happy_hour.HH_ID (INT), happy_hour.Shop_ID (INT), happy_hour.Month (TEXT), happy_hour.Num_of_shaff_in_charge (INT), ) Table happy_hour_member ( happy_hour_member.HH_ID (INT), happy_hour_member.Member_ID (INT), happy_hour_member.Total_amount (REAL), ) Table member ( member.Member_ID (INT), member.Name (TEXT), member.Membership_card (TEXT), member.Age (INT), member.Time_of_purchase (INT), member.Level_of_membership (INT), member.Address (TEXT), ) Table shop ( shop.Shop_ID (INT), shop.Address (TEXT), shop.Num_of_staff (TEXT), shop.Score (REAL), shop.Open_Year (TEXT), ) Possible JOINs: happy_hour.Shop_ID = shop.Shop_ID happy_hour_member.Member_ID = member.Member_ID
SELECT Membership_card FROM member GROUP BY Membership_card HAVING count(*) > 5
Table happy_hour ( happy_hour.hh_id (INT), happy_hour.shop_id (INT), happy_hour.month (TEXT), happy_hour.num_of_shaff_in_charge (INT), ) Table happy_hour_member ( happy_hour_member.hh_id (INT), happy_hour_member.member_id (INT), happy_hour_member.total_amount (REAL), ) Table member ( member.member_id (INT), member.name (TEXT), member.membership_card (TEXT), member.age (INT), member.time_of_purchase (INT), member.level_of_membership (INT), member.address (TEXT), ) Table shop ( shop.shop_id (INT), shop.address (TEXT), shop.num_of_staff (TEXT), shop.score (REAL), shop.open_year (TEXT), ) Possible JOINs: happy_hour.shop_id = shop.shop_id happy_hour_member.member_id = member.member_id
{ 'shop': ['shop_id', 'address', 'num_of_staff', 'score', 'open_year'], 'member': ['member_id', 'name', 'membership_card', 'age', 'time_of_purchase', 'level_of_membership', 'address'], 'happy_hour': ['hh_id', 'shop_id', 'month', 'num_of_shaff_in_charge'], 'happy_hour_member': ['hh_id', 'member_id', 'total_amount'] }
{ 'member': ['member_id', 'membership_card'] }
TABLE member ( member.Member_ID (INT), member.Membership_card (TEXT), ) Possible JOINs:
TABLE member ( member.Member_ID (INT), member.Name (TEXT), member.Membership_card (TEXT), member.Age (INT), member.Time_of_purchase (INT), member.Level_of_membership (INT), member.Address (TEXT), ) Possible JOINs:
coffee_shop
Which address has both members younger than 30 and members older than 40?
hard
Table happy_hour ( happy_hour.HH_ID (INT), happy_hour.Shop_ID (INT), happy_hour.Month (TEXT), happy_hour.Num_of_shaff_in_charge (INT), ) Table happy_hour_member ( happy_hour_member.HH_ID (INT), happy_hour_member.Member_ID (INT), happy_hour_member.Total_amount (REAL), ) Table member ( member.Member_ID (INT), member.Name (TEXT), member.Membership_card (TEXT), member.Age (INT), member.Time_of_purchase (INT), member.Level_of_membership (INT), member.Address (TEXT), ) Table shop ( shop.Shop_ID (INT), shop.Address (TEXT), shop.Num_of_staff (TEXT), shop.Score (REAL), shop.Open_Year (TEXT), ) Possible JOINs: happy_hour.Shop_ID = shop.Shop_ID happy_hour_member.Member_ID = member.Member_ID
SELECT address FROM member WHERE age < 30 INTERSECT SELECT address FROM member WHERE age > 40
Table happy_hour ( happy_hour.hh_id (INT), happy_hour.shop_id (INT), happy_hour.month (TEXT), happy_hour.num_of_shaff_in_charge (INT), ) Table happy_hour_member ( happy_hour_member.hh_id (INT), happy_hour_member.member_id (INT), happy_hour_member.total_amount (REAL), ) Table member ( member.member_id (INT), member.name (TEXT), member.membership_card (TEXT), member.age (INT), member.time_of_purchase (INT), member.level_of_membership (INT), member.address (TEXT), ) Table shop ( shop.shop_id (INT), shop.address (TEXT), shop.num_of_staff (TEXT), shop.score (REAL), shop.open_year (TEXT), ) Possible JOINs: happy_hour.shop_id = shop.shop_id happy_hour_member.member_id = member.member_id
{ 'shop': ['shop_id', 'address', 'num_of_staff', 'score', 'open_year'], 'member': ['member_id', 'name', 'membership_card', 'age', 'time_of_purchase', 'level_of_membership', 'address'], 'happy_hour': ['hh_id', 'shop_id', 'month', 'num_of_shaff_in_charge'], 'happy_hour_member': ['hh_id', 'member_id', 'total_amount'] }
{ 'member': ['member_id', 'age', 'address'] }
TABLE member ( member.Member_ID (INT), member.Age (INT), member.Address (TEXT), ) Possible JOINs:
TABLE member ( member.Member_ID (INT), member.Name (TEXT), member.Membership_card (TEXT), member.Age (INT), member.Time_of_purchase (INT), member.Level_of_membership (INT), member.Address (TEXT), ) Possible JOINs:
coffee_shop
What is the membership card held by both members living in Hartford and ones living in Waterbury address?
hard
Table happy_hour ( happy_hour.HH_ID (INT), happy_hour.Shop_ID (INT), happy_hour.Month (TEXT), happy_hour.Num_of_shaff_in_charge (INT), ) Table happy_hour_member ( happy_hour_member.HH_ID (INT), happy_hour_member.Member_ID (INT), happy_hour_member.Total_amount (REAL), ) Table member ( member.Member_ID (INT), member.Name (TEXT), member.Membership_card (TEXT), member.Age (INT), member.Time_of_purchase (INT), member.Level_of_membership (INT), member.Address (TEXT), ) Table shop ( shop.Shop_ID (INT), shop.Address (TEXT), shop.Num_of_staff (TEXT), shop.Score (REAL), shop.Open_Year (TEXT), ) Possible JOINs: happy_hour.Shop_ID = shop.Shop_ID happy_hour_member.Member_ID = member.Member_ID
SELECT membership_card FROM member WHERE address = 'Hartford' INTERSECT SELECT membership_card FROM member WHERE address = 'Waterbury'
Table happy_hour ( happy_hour.hh_id (INT), happy_hour.shop_id (INT), happy_hour.month (TEXT), happy_hour.num_of_shaff_in_charge (INT), ) Table happy_hour_member ( happy_hour_member.hh_id (INT), happy_hour_member.member_id (INT), happy_hour_member.total_amount (REAL), ) Table member ( member.member_id (INT), member.name (TEXT), member.membership_card (TEXT), member.age (INT), member.time_of_purchase (INT), member.level_of_membership (INT), member.address (TEXT), ) Table shop ( shop.shop_id (INT), shop.address (TEXT), shop.num_of_staff (TEXT), shop.score (REAL), shop.open_year (TEXT), ) Possible JOINs: happy_hour.shop_id = shop.shop_id happy_hour_member.member_id = member.member_id
{ 'shop': ['shop_id', 'address', 'num_of_staff', 'score', 'open_year'], 'member': ['member_id', 'name', 'membership_card', 'age', 'time_of_purchase', 'level_of_membership', 'address'], 'happy_hour': ['hh_id', 'shop_id', 'month', 'num_of_shaff_in_charge'], 'happy_hour_member': ['hh_id', 'member_id', 'total_amount'] }
{ 'member': ['member_id', 'membership_card', 'address'] }
TABLE member ( member.Member_ID (INT), member.Membership_card (TEXT), member.Address (TEXT), ) Possible JOINs:
TABLE member ( member.Member_ID (INT), member.Name (TEXT), member.Membership_card (TEXT), member.Age (INT), member.Time_of_purchase (INT), member.Level_of_membership (INT), member.Address (TEXT), ) Possible JOINs:
coffee_shop
How many members are not living in Hartford?
easy
Table happy_hour ( happy_hour.HH_ID (INT), happy_hour.Shop_ID (INT), happy_hour.Month (TEXT), happy_hour.Num_of_shaff_in_charge (INT), ) Table happy_hour_member ( happy_hour_member.HH_ID (INT), happy_hour_member.Member_ID (INT), happy_hour_member.Total_amount (REAL), ) Table member ( member.Member_ID (INT), member.Name (TEXT), member.Membership_card (TEXT), member.Age (INT), member.Time_of_purchase (INT), member.Level_of_membership (INT), member.Address (TEXT), ) Table shop ( shop.Shop_ID (INT), shop.Address (TEXT), shop.Num_of_staff (TEXT), shop.Score (REAL), shop.Open_Year (TEXT), ) Possible JOINs: happy_hour.Shop_ID = shop.Shop_ID happy_hour_member.Member_ID = member.Member_ID
SELECT count(*) FROM member WHERE address != 'Hartford'
Table happy_hour ( happy_hour.hh_id (INT), happy_hour.shop_id (INT), happy_hour.month (TEXT), happy_hour.num_of_shaff_in_charge (INT), ) Table happy_hour_member ( happy_hour_member.hh_id (INT), happy_hour_member.member_id (INT), happy_hour_member.total_amount (REAL), ) Table member ( member.member_id (INT), member.name (TEXT), member.membership_card (TEXT), member.age (INT), member.time_of_purchase (INT), member.level_of_membership (INT), member.address (TEXT), ) Table shop ( shop.shop_id (INT), shop.address (TEXT), shop.num_of_staff (TEXT), shop.score (REAL), shop.open_year (TEXT), ) Possible JOINs: happy_hour.shop_id = shop.shop_id happy_hour_member.member_id = member.member_id
{ 'shop': ['shop_id', 'address', 'num_of_staff', 'score', 'open_year'], 'member': ['member_id', 'name', 'membership_card', 'age', 'time_of_purchase', 'level_of_membership', 'address'], 'happy_hour': ['hh_id', 'shop_id', 'month', 'num_of_shaff_in_charge'], 'happy_hour_member': ['hh_id', 'member_id', 'total_amount'] }
{ 'member': ['member_id', 'address'] }
TABLE member ( member.Member_ID (INT), member.Address (TEXT), ) Possible JOINs:
TABLE member ( member.Member_ID (INT), member.Name (TEXT), member.Membership_card (TEXT), member.Age (INT), member.Time_of_purchase (INT), member.Level_of_membership (INT), member.Address (TEXT), ) Possible JOINs:
coffee_shop
Which address do not have any member with the black membership card?
hard
Table happy_hour ( happy_hour.HH_ID (INT), happy_hour.Shop_ID (INT), happy_hour.Month (TEXT), happy_hour.Num_of_shaff_in_charge (INT), ) Table happy_hour_member ( happy_hour_member.HH_ID (INT), happy_hour_member.Member_ID (INT), happy_hour_member.Total_amount (REAL), ) Table member ( member.Member_ID (INT), member.Name (TEXT), member.Membership_card (TEXT), member.Age (INT), member.Time_of_purchase (INT), member.Level_of_membership (INT), member.Address (TEXT), ) Table shop ( shop.Shop_ID (INT), shop.Address (TEXT), shop.Num_of_staff (TEXT), shop.Score (REAL), shop.Open_Year (TEXT), ) Possible JOINs: happy_hour.Shop_ID = shop.Shop_ID happy_hour_member.Member_ID = member.Member_ID
SELECT address FROM member EXCEPT SELECT address FROM member WHERE Membership_card = 'Black'
Table happy_hour ( happy_hour.hh_id (INT), happy_hour.shop_id (INT), happy_hour.month (TEXT), happy_hour.num_of_shaff_in_charge (INT), ) Table happy_hour_member ( happy_hour_member.hh_id (INT), happy_hour_member.member_id (INT), happy_hour_member.total_amount (REAL), ) Table member ( member.member_id (INT), member.name (TEXT), member.membership_card (TEXT), member.age (INT), member.time_of_purchase (INT), member.level_of_membership (INT), member.address (TEXT), ) Table shop ( shop.shop_id (INT), shop.address (TEXT), shop.num_of_staff (TEXT), shop.score (REAL), shop.open_year (TEXT), ) Possible JOINs: happy_hour.shop_id = shop.shop_id happy_hour_member.member_id = member.member_id
{ 'shop': ['shop_id', 'address', 'num_of_staff', 'score', 'open_year'], 'member': ['member_id', 'name', 'membership_card', 'age', 'time_of_purchase', 'level_of_membership', 'address'], 'happy_hour': ['hh_id', 'shop_id', 'month', 'num_of_shaff_in_charge'], 'happy_hour_member': ['hh_id', 'member_id', 'total_amount'] }
{ 'member': ['member_id', 'membership_card', 'address'] }
TABLE member ( member.Member_ID (INT), member.Membership_card (TEXT), member.Address (TEXT), ) Possible JOINs:
TABLE member ( member.Member_ID (INT), member.Name (TEXT), member.Membership_card (TEXT), member.Age (INT), member.Time_of_purchase (INT), member.Level_of_membership (INT), member.Address (TEXT), ) Possible JOINs:
coffee_shop
Show the shop addresses ordered by their opening year.
easy
Table happy_hour ( happy_hour.HH_ID (INT), happy_hour.Shop_ID (INT), happy_hour.Month (TEXT), happy_hour.Num_of_shaff_in_charge (INT), ) Table happy_hour_member ( happy_hour_member.HH_ID (INT), happy_hour_member.Member_ID (INT), happy_hour_member.Total_amount (REAL), ) Table member ( member.Member_ID (INT), member.Name (TEXT), member.Membership_card (TEXT), member.Age (INT), member.Time_of_purchase (INT), member.Level_of_membership (INT), member.Address (TEXT), ) Table shop ( shop.Shop_ID (INT), shop.Address (TEXT), shop.Num_of_staff (TEXT), shop.Score (REAL), shop.Open_Year (TEXT), ) Possible JOINs: happy_hour.Shop_ID = shop.Shop_ID happy_hour_member.Member_ID = member.Member_ID
SELECT address FROM shop ORDER BY open_year
Table happy_hour ( happy_hour.hh_id (INT), happy_hour.shop_id (INT), happy_hour.month (TEXT), happy_hour.num_of_shaff_in_charge (INT), ) Table happy_hour_member ( happy_hour_member.hh_id (INT), happy_hour_member.member_id (INT), happy_hour_member.total_amount (REAL), ) Table member ( member.member_id (INT), member.name (TEXT), member.membership_card (TEXT), member.age (INT), member.time_of_purchase (INT), member.level_of_membership (INT), member.address (TEXT), ) Table shop ( shop.shop_id (INT), shop.address (TEXT), shop.num_of_staff (TEXT), shop.score (REAL), shop.open_year (TEXT), ) Possible JOINs: happy_hour.shop_id = shop.shop_id happy_hour_member.member_id = member.member_id
{ 'shop': ['shop_id', 'address', 'num_of_staff', 'score', 'open_year'], 'member': ['member_id', 'name', 'membership_card', 'age', 'time_of_purchase', 'level_of_membership', 'address'], 'happy_hour': ['hh_id', 'shop_id', 'month', 'num_of_shaff_in_charge'], 'happy_hour_member': ['hh_id', 'member_id', 'total_amount'] }
{ 'shop': ['shop_id', 'address', 'open_year'] }
TABLE shop ( shop.Shop_ID (INT), shop.Address (TEXT), shop.Open_Year (TEXT), ) Possible JOINs:
TABLE shop ( shop.Shop_ID (INT), shop.Address (TEXT), shop.Num_of_staff (TEXT), shop.Score (REAL), shop.Open_Year (TEXT), ) Possible JOINs: