SQL
stringlengths
18
577
question
stringlengths
317
11.5k
SELECT card_id , customer_id , card_type_code , card_number FROM Customers_cards
Given the Table accounts having columns as account_id has datatype number, customer_id has datatype number, account_name has datatype text, other_account_details has datatype text which has account_id and Given the Table customers having columns as customer_id has datatype number, customer_first_name has datatype text, customer_last_name has datatype text, customer_address has datatype text, customer_phone has datatype text, customer_email has datatype text, other_customer_details has datatype text which has customer_id and Given the Table customers cards having columns as card_id has datatype number, customer_id has datatype number, card_type_code has datatype text, card_number has datatype text, date_valid_from has datatype time, date_valid_to has datatype time, other_card_details has datatype text which has card_id and Given the Table financial transactions having columns as transaction_id has datatype number, previous_transaction_id has datatype number, account_id has datatype number, card_id has datatype number, transaction_type has datatype text, transaction_date has datatype time, transaction_amount has datatype number, transaction_comment has datatype text, other_transaction_details has datatype text which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. What are card ids, customer ids, card types, and card numbers for each customer card?
SELECT date_valid_from , date_valid_to FROM Customers_cards WHERE card_number = "4560596484842"
Given the Table accounts having columns as account_id has datatype number, customer_id has datatype number, account_name has datatype text, other_account_details has datatype text which has account_id and Given the Table customers having columns as customer_id has datatype number, customer_first_name has datatype text, customer_last_name has datatype text, customer_address has datatype text, customer_phone has datatype text, customer_email has datatype text, other_customer_details has datatype text which has customer_id and Given the Table customers cards having columns as card_id has datatype number, customer_id has datatype number, card_type_code has datatype text, card_number has datatype text, date_valid_from has datatype time, date_valid_to has datatype time, other_card_details has datatype text which has card_id and Given the Table financial transactions having columns as transaction_id has datatype number, previous_transaction_id has datatype number, account_id has datatype number, card_id has datatype number, transaction_type has datatype text, transaction_date has datatype time, transaction_amount has datatype number, transaction_comment has datatype text, other_transaction_details has datatype text which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. Show the date valid from and the date valid to for the card with card number '4560596484842'.
SELECT date_valid_from , date_valid_to FROM Customers_cards WHERE card_number = "4560596484842"
Given the Table accounts having columns as account_id has datatype number, customer_id has datatype number, account_name has datatype text, other_account_details has datatype text which has account_id and Given the Table customers having columns as customer_id has datatype number, customer_first_name has datatype text, customer_last_name has datatype text, customer_address has datatype text, customer_phone has datatype text, customer_email has datatype text, other_customer_details has datatype text which has customer_id and Given the Table customers cards having columns as card_id has datatype number, customer_id has datatype number, card_type_code has datatype text, card_number has datatype text, date_valid_from has datatype time, date_valid_to has datatype time, other_card_details has datatype text which has card_id and Given the Table financial transactions having columns as transaction_id has datatype number, previous_transaction_id has datatype number, account_id has datatype number, card_id has datatype number, transaction_type has datatype text, transaction_date has datatype time, transaction_amount has datatype number, transaction_comment has datatype text, other_transaction_details has datatype text which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. What are the valid from and valid to dates for the card with the number 4560596484842?
SELECT T2.customer_first_name , T2.customer_last_name , T2.customer_phone FROM Customers_cards AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id WHERE T1.card_number = "4560596484842"
Given the Table accounts having columns as account_id has datatype number, customer_id has datatype number, account_name has datatype text, other_account_details has datatype text which has account_id and Given the Table customers having columns as customer_id has datatype number, customer_first_name has datatype text, customer_last_name has datatype text, customer_address has datatype text, customer_phone has datatype text, customer_email has datatype text, other_customer_details has datatype text which has customer_id and Given the Table customers cards having columns as card_id has datatype number, customer_id has datatype number, card_type_code has datatype text, card_number has datatype text, date_valid_from has datatype time, date_valid_to has datatype time, other_card_details has datatype text which has card_id and Given the Table financial transactions having columns as transaction_id has datatype number, previous_transaction_id has datatype number, account_id has datatype number, card_id has datatype number, transaction_type has datatype text, transaction_date has datatype time, transaction_amount has datatype number, transaction_comment has datatype text, other_transaction_details has datatype text which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. What is the first name, last name, and phone of the customer with card 4560596484842.
SELECT T2.customer_first_name , T2.customer_last_name , T2.customer_phone FROM Customers_cards AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id WHERE T1.card_number = "4560596484842"
Given the Table accounts having columns as account_id has datatype number, customer_id has datatype number, account_name has datatype text, other_account_details has datatype text which has account_id and Given the Table customers having columns as customer_id has datatype number, customer_first_name has datatype text, customer_last_name has datatype text, customer_address has datatype text, customer_phone has datatype text, customer_email has datatype text, other_customer_details has datatype text which has customer_id and Given the Table customers cards having columns as card_id has datatype number, customer_id has datatype number, card_type_code has datatype text, card_number has datatype text, date_valid_from has datatype time, date_valid_to has datatype time, other_card_details has datatype text which has card_id and Given the Table financial transactions having columns as transaction_id has datatype number, previous_transaction_id has datatype number, account_id has datatype number, card_id has datatype number, transaction_type has datatype text, transaction_date has datatype time, transaction_amount has datatype number, transaction_comment has datatype text, other_transaction_details has datatype text which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. Return the full name and phone of the customer who has card number 4560596484842.
SELECT count(*) FROM Customers_cards AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id WHERE T2.customer_first_name = "Art" AND T2.customer_last_name = "Turcotte"
Given the Table accounts having columns as account_id has datatype number, customer_id has datatype number, account_name has datatype text, other_account_details has datatype text which has account_id and Given the Table customers having columns as customer_id has datatype number, customer_first_name has datatype text, customer_last_name has datatype text, customer_address has datatype text, customer_phone has datatype text, customer_email has datatype text, other_customer_details has datatype text which has customer_id and Given the Table customers cards having columns as card_id has datatype number, customer_id has datatype number, card_type_code has datatype text, card_number has datatype text, date_valid_from has datatype time, date_valid_to has datatype time, other_card_details has datatype text which has card_id and Given the Table financial transactions having columns as transaction_id has datatype number, previous_transaction_id has datatype number, account_id has datatype number, card_id has datatype number, transaction_type has datatype text, transaction_date has datatype time, transaction_amount has datatype number, transaction_comment has datatype text, other_transaction_details has datatype text which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. How many cards does customer Art Turcotte have?
SELECT count(*) FROM Customers_cards AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id WHERE T2.customer_first_name = "Art" AND T2.customer_last_name = "Turcotte"
Given the Table accounts having columns as account_id has datatype number, customer_id has datatype number, account_name has datatype text, other_account_details has datatype text which has account_id and Given the Table customers having columns as customer_id has datatype number, customer_first_name has datatype text, customer_last_name has datatype text, customer_address has datatype text, customer_phone has datatype text, customer_email has datatype text, other_customer_details has datatype text which has customer_id and Given the Table customers cards having columns as card_id has datatype number, customer_id has datatype number, card_type_code has datatype text, card_number has datatype text, date_valid_from has datatype time, date_valid_to has datatype time, other_card_details has datatype text which has card_id and Given the Table financial transactions having columns as transaction_id has datatype number, previous_transaction_id has datatype number, account_id has datatype number, card_id has datatype number, transaction_type has datatype text, transaction_date has datatype time, transaction_amount has datatype number, transaction_comment has datatype text, other_transaction_details has datatype text which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. Count the number of cards the customer with the first name Art and last name Turcotte has.
SELECT count(*) FROM Customers_cards WHERE card_type_code = "Debit"
Given the Table accounts having columns as account_id has datatype number, customer_id has datatype number, account_name has datatype text, other_account_details has datatype text which has account_id and Given the Table customers having columns as customer_id has datatype number, customer_first_name has datatype text, customer_last_name has datatype text, customer_address has datatype text, customer_phone has datatype text, customer_email has datatype text, other_customer_details has datatype text which has customer_id and Given the Table customers cards having columns as card_id has datatype number, customer_id has datatype number, card_type_code has datatype text, card_number has datatype text, date_valid_from has datatype time, date_valid_to has datatype time, other_card_details has datatype text which has card_id and Given the Table financial transactions having columns as transaction_id has datatype number, previous_transaction_id has datatype number, account_id has datatype number, card_id has datatype number, transaction_type has datatype text, transaction_date has datatype time, transaction_amount has datatype number, transaction_comment has datatype text, other_transaction_details has datatype text which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. How many debit cards do we have?
SELECT count(*) FROM Customers_cards WHERE card_type_code = "Debit"
Given the Table accounts having columns as account_id has datatype number, customer_id has datatype number, account_name has datatype text, other_account_details has datatype text which has account_id and Given the Table customers having columns as customer_id has datatype number, customer_first_name has datatype text, customer_last_name has datatype text, customer_address has datatype text, customer_phone has datatype text, customer_email has datatype text, other_customer_details has datatype text which has customer_id and Given the Table customers cards having columns as card_id has datatype number, customer_id has datatype number, card_type_code has datatype text, card_number has datatype text, date_valid_from has datatype time, date_valid_to has datatype time, other_card_details has datatype text which has card_id and Given the Table financial transactions having columns as transaction_id has datatype number, previous_transaction_id has datatype number, account_id has datatype number, card_id has datatype number, transaction_type has datatype text, transaction_date has datatype time, transaction_amount has datatype number, transaction_comment has datatype text, other_transaction_details has datatype text which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. Count the number of customer cards of the type Debit.
SELECT count(*) FROM Customers_cards AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id WHERE T2.customer_first_name = "Blanche" AND T2.customer_last_name = "Huels" AND T1.card_type_code = "Credit"
Given the Table accounts having columns as account_id has datatype number, customer_id has datatype number, account_name has datatype text, other_account_details has datatype text which has account_id and Given the Table customers having columns as customer_id has datatype number, customer_first_name has datatype text, customer_last_name has datatype text, customer_address has datatype text, customer_phone has datatype text, customer_email has datatype text, other_customer_details has datatype text which has customer_id and Given the Table customers cards having columns as card_id has datatype number, customer_id has datatype number, card_type_code has datatype text, card_number has datatype text, date_valid_from has datatype time, date_valid_to has datatype time, other_card_details has datatype text which has card_id and Given the Table financial transactions having columns as transaction_id has datatype number, previous_transaction_id has datatype number, account_id has datatype number, card_id has datatype number, transaction_type has datatype text, transaction_date has datatype time, transaction_amount has datatype number, transaction_comment has datatype text, other_transaction_details has datatype text which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. How many credit cards does customer Blanche Huels have?
SELECT count(*) FROM Customers_cards AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id WHERE T2.customer_first_name = "Blanche" AND T2.customer_last_name = "Huels" AND T1.card_type_code = "Credit"
Given the Table accounts having columns as account_id has datatype number, customer_id has datatype number, account_name has datatype text, other_account_details has datatype text which has account_id and Given the Table customers having columns as customer_id has datatype number, customer_first_name has datatype text, customer_last_name has datatype text, customer_address has datatype text, customer_phone has datatype text, customer_email has datatype text, other_customer_details has datatype text which has customer_id and Given the Table customers cards having columns as card_id has datatype number, customer_id has datatype number, card_type_code has datatype text, card_number has datatype text, date_valid_from has datatype time, date_valid_to has datatype time, other_card_details has datatype text which has card_id and Given the Table financial transactions having columns as transaction_id has datatype number, previous_transaction_id has datatype number, account_id has datatype number, card_id has datatype number, transaction_type has datatype text, transaction_date has datatype time, transaction_amount has datatype number, transaction_comment has datatype text, other_transaction_details has datatype text which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. Count the number of credit cards that the customer with first name Blanche and last name Huels has.
SELECT customer_id , count(*) FROM Customers_cards GROUP BY customer_id
Given the Table accounts having columns as account_id has datatype number, customer_id has datatype number, account_name has datatype text, other_account_details has datatype text which has account_id and Given the Table customers having columns as customer_id has datatype number, customer_first_name has datatype text, customer_last_name has datatype text, customer_address has datatype text, customer_phone has datatype text, customer_email has datatype text, other_customer_details has datatype text which has customer_id and Given the Table customers cards having columns as card_id has datatype number, customer_id has datatype number, card_type_code has datatype text, card_number has datatype text, date_valid_from has datatype time, date_valid_to has datatype time, other_card_details has datatype text which has card_id and Given the Table financial transactions having columns as transaction_id has datatype number, previous_transaction_id has datatype number, account_id has datatype number, card_id has datatype number, transaction_type has datatype text, transaction_date has datatype time, transaction_amount has datatype number, transaction_comment has datatype text, other_transaction_details has datatype text which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. Show all customer ids and the number of cards owned by each customer.
SELECT customer_id , count(*) FROM Customers_cards GROUP BY customer_id
Given the Table accounts having columns as account_id has datatype number, customer_id has datatype number, account_name has datatype text, other_account_details has datatype text which has account_id and Given the Table customers having columns as customer_id has datatype number, customer_first_name has datatype text, customer_last_name has datatype text, customer_address has datatype text, customer_phone has datatype text, customer_email has datatype text, other_customer_details has datatype text which has customer_id and Given the Table customers cards having columns as card_id has datatype number, customer_id has datatype number, card_type_code has datatype text, card_number has datatype text, date_valid_from has datatype time, date_valid_to has datatype time, other_card_details has datatype text which has card_id and Given the Table financial transactions having columns as transaction_id has datatype number, previous_transaction_id has datatype number, account_id has datatype number, card_id has datatype number, transaction_type has datatype text, transaction_date has datatype time, transaction_amount has datatype number, transaction_comment has datatype text, other_transaction_details has datatype text which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. What are the different customer ids, and how many cards does each one hold?
SELECT customer_id , count(*) FROM Customers_cards GROUP BY customer_id ORDER BY count(*) DESC LIMIT 1
Given the Table accounts having columns as account_id has datatype number, customer_id has datatype number, account_name has datatype text, other_account_details has datatype text which has account_id and Given the Table customers having columns as customer_id has datatype number, customer_first_name has datatype text, customer_last_name has datatype text, customer_address has datatype text, customer_phone has datatype text, customer_email has datatype text, other_customer_details has datatype text which has customer_id and Given the Table customers cards having columns as card_id has datatype number, customer_id has datatype number, card_type_code has datatype text, card_number has datatype text, date_valid_from has datatype time, date_valid_to has datatype time, other_card_details has datatype text which has card_id and Given the Table financial transactions having columns as transaction_id has datatype number, previous_transaction_id has datatype number, account_id has datatype number, card_id has datatype number, transaction_type has datatype text, transaction_date has datatype time, transaction_amount has datatype number, transaction_comment has datatype text, other_transaction_details has datatype text which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. What is the customer id with most number of cards, and how many does he have?
SELECT customer_id , count(*) FROM Customers_cards GROUP BY customer_id ORDER BY count(*) DESC LIMIT 1
Given the Table accounts having columns as account_id has datatype number, customer_id has datatype number, account_name has datatype text, other_account_details has datatype text which has account_id and Given the Table customers having columns as customer_id has datatype number, customer_first_name has datatype text, customer_last_name has datatype text, customer_address has datatype text, customer_phone has datatype text, customer_email has datatype text, other_customer_details has datatype text which has customer_id and Given the Table customers cards having columns as card_id has datatype number, customer_id has datatype number, card_type_code has datatype text, card_number has datatype text, date_valid_from has datatype time, date_valid_to has datatype time, other_card_details has datatype text which has card_id and Given the Table financial transactions having columns as transaction_id has datatype number, previous_transaction_id has datatype number, account_id has datatype number, card_id has datatype number, transaction_type has datatype text, transaction_date has datatype time, transaction_amount has datatype number, transaction_comment has datatype text, other_transaction_details has datatype text which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. Return the id of the customer who has the most cards, as well as the number of cards.
SELECT T1.customer_id , T2.customer_first_name , T2.customer_last_name FROM Customers_cards AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id HAVING count(*) >= 2
Given the Table accounts having columns as account_id has datatype number, customer_id has datatype number, account_name has datatype text, other_account_details has datatype text which has account_id and Given the Table customers having columns as customer_id has datatype number, customer_first_name has datatype text, customer_last_name has datatype text, customer_address has datatype text, customer_phone has datatype text, customer_email has datatype text, other_customer_details has datatype text which has customer_id and Given the Table customers cards having columns as card_id has datatype number, customer_id has datatype number, card_type_code has datatype text, card_number has datatype text, date_valid_from has datatype time, date_valid_to has datatype time, other_card_details has datatype text which has card_id and Given the Table financial transactions having columns as transaction_id has datatype number, previous_transaction_id has datatype number, account_id has datatype number, card_id has datatype number, transaction_type has datatype text, transaction_date has datatype time, transaction_amount has datatype number, transaction_comment has datatype text, other_transaction_details has datatype text which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. Show id, first and last names for all customers with at least two cards.
SELECT T1.customer_id , T2.customer_first_name , T2.customer_last_name FROM Customers_cards AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id HAVING count(*) >= 2
Given the Table accounts having columns as account_id has datatype number, customer_id has datatype number, account_name has datatype text, other_account_details has datatype text which has account_id and Given the Table customers having columns as customer_id has datatype number, customer_first_name has datatype text, customer_last_name has datatype text, customer_address has datatype text, customer_phone has datatype text, customer_email has datatype text, other_customer_details has datatype text which has customer_id and Given the Table customers cards having columns as card_id has datatype number, customer_id has datatype number, card_type_code has datatype text, card_number has datatype text, date_valid_from has datatype time, date_valid_to has datatype time, other_card_details has datatype text which has card_id and Given the Table financial transactions having columns as transaction_id has datatype number, previous_transaction_id has datatype number, account_id has datatype number, card_id has datatype number, transaction_type has datatype text, transaction_date has datatype time, transaction_amount has datatype number, transaction_comment has datatype text, other_transaction_details has datatype text which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. What are the ids and full names of customers who hold two or more cards?
SELECT T1.customer_id , T2.customer_first_name , T2.customer_last_name FROM Customers_cards AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id ORDER BY count(*) ASC LIMIT 1
Given the Table accounts having columns as account_id has datatype number, customer_id has datatype number, account_name has datatype text, other_account_details has datatype text which has account_id and Given the Table customers having columns as customer_id has datatype number, customer_first_name has datatype text, customer_last_name has datatype text, customer_address has datatype text, customer_phone has datatype text, customer_email has datatype text, other_customer_details has datatype text which has customer_id and Given the Table customers cards having columns as card_id has datatype number, customer_id has datatype number, card_type_code has datatype text, card_number has datatype text, date_valid_from has datatype time, date_valid_to has datatype time, other_card_details has datatype text which has card_id and Given the Table financial transactions having columns as transaction_id has datatype number, previous_transaction_id has datatype number, account_id has datatype number, card_id has datatype number, transaction_type has datatype text, transaction_date has datatype time, transaction_amount has datatype number, transaction_comment has datatype text, other_transaction_details has datatype text which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. What is the customer id, first and last name with least number of accounts.
SELECT T1.customer_id , T2.customer_first_name , T2.customer_last_name FROM Customers_cards AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id ORDER BY count(*) ASC LIMIT 1
Given the Table accounts having columns as account_id has datatype number, customer_id has datatype number, account_name has datatype text, other_account_details has datatype text which has account_id and Given the Table customers having columns as customer_id has datatype number, customer_first_name has datatype text, customer_last_name has datatype text, customer_address has datatype text, customer_phone has datatype text, customer_email has datatype text, other_customer_details has datatype text which has customer_id and Given the Table customers cards having columns as card_id has datatype number, customer_id has datatype number, card_type_code has datatype text, card_number has datatype text, date_valid_from has datatype time, date_valid_to has datatype time, other_card_details has datatype text which has card_id and Given the Table financial transactions having columns as transaction_id has datatype number, previous_transaction_id has datatype number, account_id has datatype number, card_id has datatype number, transaction_type has datatype text, transaction_date has datatype time, transaction_amount has datatype number, transaction_comment has datatype text, other_transaction_details has datatype text which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. Return the id and full name of the customer who has the fewest accounts.
SELECT card_type_code , count(*) FROM Customers_cards GROUP BY card_type_code
Given the Table accounts having columns as account_id has datatype number, customer_id has datatype number, account_name has datatype text, other_account_details has datatype text which has account_id and Given the Table customers having columns as customer_id has datatype number, customer_first_name has datatype text, customer_last_name has datatype text, customer_address has datatype text, customer_phone has datatype text, customer_email has datatype text, other_customer_details has datatype text which has customer_id and Given the Table customers cards having columns as card_id has datatype number, customer_id has datatype number, card_type_code has datatype text, card_number has datatype text, date_valid_from has datatype time, date_valid_to has datatype time, other_card_details has datatype text which has card_id and Given the Table financial transactions having columns as transaction_id has datatype number, previous_transaction_id has datatype number, account_id has datatype number, card_id has datatype number, transaction_type has datatype text, transaction_date has datatype time, transaction_amount has datatype number, transaction_comment has datatype text, other_transaction_details has datatype text which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. Show all card type codes and the number of cards in each type.
SELECT card_type_code , count(*) FROM Customers_cards GROUP BY card_type_code
Given the Table accounts having columns as account_id has datatype number, customer_id has datatype number, account_name has datatype text, other_account_details has datatype text which has account_id and Given the Table customers having columns as customer_id has datatype number, customer_first_name has datatype text, customer_last_name has datatype text, customer_address has datatype text, customer_phone has datatype text, customer_email has datatype text, other_customer_details has datatype text which has customer_id and Given the Table customers cards having columns as card_id has datatype number, customer_id has datatype number, card_type_code has datatype text, card_number has datatype text, date_valid_from has datatype time, date_valid_to has datatype time, other_card_details has datatype text which has card_id and Given the Table financial transactions having columns as transaction_id has datatype number, previous_transaction_id has datatype number, account_id has datatype number, card_id has datatype number, transaction_type has datatype text, transaction_date has datatype time, transaction_amount has datatype number, transaction_comment has datatype text, other_transaction_details has datatype text which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. What are the different card types, and how many cards are there of each?
SELECT card_type_code FROM Customers_cards GROUP BY card_type_code ORDER BY count(*) DESC LIMIT 1
Given the Table accounts having columns as account_id has datatype number, customer_id has datatype number, account_name has datatype text, other_account_details has datatype text which has account_id and Given the Table customers having columns as customer_id has datatype number, customer_first_name has datatype text, customer_last_name has datatype text, customer_address has datatype text, customer_phone has datatype text, customer_email has datatype text, other_customer_details has datatype text which has customer_id and Given the Table customers cards having columns as card_id has datatype number, customer_id has datatype number, card_type_code has datatype text, card_number has datatype text, date_valid_from has datatype time, date_valid_to has datatype time, other_card_details has datatype text which has card_id and Given the Table financial transactions having columns as transaction_id has datatype number, previous_transaction_id has datatype number, account_id has datatype number, card_id has datatype number, transaction_type has datatype text, transaction_date has datatype time, transaction_amount has datatype number, transaction_comment has datatype text, other_transaction_details has datatype text which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. What is the card type code with most number of cards?
SELECT card_type_code FROM Customers_cards GROUP BY card_type_code ORDER BY count(*) DESC LIMIT 1
Given the Table accounts having columns as account_id has datatype number, customer_id has datatype number, account_name has datatype text, other_account_details has datatype text which has account_id and Given the Table customers having columns as customer_id has datatype number, customer_first_name has datatype text, customer_last_name has datatype text, customer_address has datatype text, customer_phone has datatype text, customer_email has datatype text, other_customer_details has datatype text which has customer_id and Given the Table customers cards having columns as card_id has datatype number, customer_id has datatype number, card_type_code has datatype text, card_number has datatype text, date_valid_from has datatype time, date_valid_to has datatype time, other_card_details has datatype text which has card_id and Given the Table financial transactions having columns as transaction_id has datatype number, previous_transaction_id has datatype number, account_id has datatype number, card_id has datatype number, transaction_type has datatype text, transaction_date has datatype time, transaction_amount has datatype number, transaction_comment has datatype text, other_transaction_details has datatype text which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. Return the code of the card type that is most common.
SELECT card_type_code FROM Customers_cards GROUP BY card_type_code HAVING count(*) >= 5
Given the Table accounts having columns as account_id has datatype number, customer_id has datatype number, account_name has datatype text, other_account_details has datatype text which has account_id and Given the Table customers having columns as customer_id has datatype number, customer_first_name has datatype text, customer_last_name has datatype text, customer_address has datatype text, customer_phone has datatype text, customer_email has datatype text, other_customer_details has datatype text which has customer_id and Given the Table customers cards having columns as card_id has datatype number, customer_id has datatype number, card_type_code has datatype text, card_number has datatype text, date_valid_from has datatype time, date_valid_to has datatype time, other_card_details has datatype text which has card_id and Given the Table financial transactions having columns as transaction_id has datatype number, previous_transaction_id has datatype number, account_id has datatype number, card_id has datatype number, transaction_type has datatype text, transaction_date has datatype time, transaction_amount has datatype number, transaction_comment has datatype text, other_transaction_details has datatype text which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. Show card type codes with at least 5 cards.
SELECT card_type_code FROM Customers_cards GROUP BY card_type_code HAVING count(*) >= 5
Given the Table accounts having columns as account_id has datatype number, customer_id has datatype number, account_name has datatype text, other_account_details has datatype text which has account_id and Given the Table customers having columns as customer_id has datatype number, customer_first_name has datatype text, customer_last_name has datatype text, customer_address has datatype text, customer_phone has datatype text, customer_email has datatype text, other_customer_details has datatype text which has customer_id and Given the Table customers cards having columns as card_id has datatype number, customer_id has datatype number, card_type_code has datatype text, card_number has datatype text, date_valid_from has datatype time, date_valid_to has datatype time, other_card_details has datatype text which has card_id and Given the Table financial transactions having columns as transaction_id has datatype number, previous_transaction_id has datatype number, account_id has datatype number, card_id has datatype number, transaction_type has datatype text, transaction_date has datatype time, transaction_amount has datatype number, transaction_comment has datatype text, other_transaction_details has datatype text which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. What are the codes of card types that have 5 or more cards?
SELECT card_type_code , count(DISTINCT customer_id) FROM Customers_cards GROUP BY card_type_code
Given the Table accounts having columns as account_id has datatype number, customer_id has datatype number, account_name has datatype text, other_account_details has datatype text which has account_id and Given the Table customers having columns as customer_id has datatype number, customer_first_name has datatype text, customer_last_name has datatype text, customer_address has datatype text, customer_phone has datatype text, customer_email has datatype text, other_customer_details has datatype text which has customer_id and Given the Table customers cards having columns as card_id has datatype number, customer_id has datatype number, card_type_code has datatype text, card_number has datatype text, date_valid_from has datatype time, date_valid_to has datatype time, other_card_details has datatype text which has card_id and Given the Table financial transactions having columns as transaction_id has datatype number, previous_transaction_id has datatype number, account_id has datatype number, card_id has datatype number, transaction_type has datatype text, transaction_date has datatype time, transaction_amount has datatype number, transaction_comment has datatype text, other_transaction_details has datatype text which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. Show all card type codes and the number of customers holding cards in each type.
SELECT card_type_code , count(DISTINCT customer_id) FROM Customers_cards GROUP BY card_type_code
Given the Table accounts having columns as account_id has datatype number, customer_id has datatype number, account_name has datatype text, other_account_details has datatype text which has account_id and Given the Table customers having columns as customer_id has datatype number, customer_first_name has datatype text, customer_last_name has datatype text, customer_address has datatype text, customer_phone has datatype text, customer_email has datatype text, other_customer_details has datatype text which has customer_id and Given the Table customers cards having columns as card_id has datatype number, customer_id has datatype number, card_type_code has datatype text, card_number has datatype text, date_valid_from has datatype time, date_valid_to has datatype time, other_card_details has datatype text which has card_id and Given the Table financial transactions having columns as transaction_id has datatype number, previous_transaction_id has datatype number, account_id has datatype number, card_id has datatype number, transaction_type has datatype text, transaction_date has datatype time, transaction_amount has datatype number, transaction_comment has datatype text, other_transaction_details has datatype text which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. What are the different card type codes, and how many different customers hold each type?
SELECT customer_id , customer_first_name FROM Customers EXCEPT SELECT T1.customer_id , T2.customer_first_name FROM Customers_cards AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id WHERE card_type_code = "Credit"
Given the Table accounts having columns as account_id has datatype number, customer_id has datatype number, account_name has datatype text, other_account_details has datatype text which has account_id and Given the Table customers having columns as customer_id has datatype number, customer_first_name has datatype text, customer_last_name has datatype text, customer_address has datatype text, customer_phone has datatype text, customer_email has datatype text, other_customer_details has datatype text which has customer_id and Given the Table customers cards having columns as card_id has datatype number, customer_id has datatype number, card_type_code has datatype text, card_number has datatype text, date_valid_from has datatype time, date_valid_to has datatype time, other_card_details has datatype text which has card_id and Given the Table financial transactions having columns as transaction_id has datatype number, previous_transaction_id has datatype number, account_id has datatype number, card_id has datatype number, transaction_type has datatype text, transaction_date has datatype time, transaction_amount has datatype number, transaction_comment has datatype text, other_transaction_details has datatype text which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. Show the customer ids and firstname without a credit card.
SELECT customer_id , customer_first_name FROM Customers EXCEPT SELECT T1.customer_id , T2.customer_first_name FROM Customers_cards AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id WHERE card_type_code = "Credit"
Given the Table accounts having columns as account_id has datatype number, customer_id has datatype number, account_name has datatype text, other_account_details has datatype text which has account_id and Given the Table customers having columns as customer_id has datatype number, customer_first_name has datatype text, customer_last_name has datatype text, customer_address has datatype text, customer_phone has datatype text, customer_email has datatype text, other_customer_details has datatype text which has customer_id and Given the Table customers cards having columns as card_id has datatype number, customer_id has datatype number, card_type_code has datatype text, card_number has datatype text, date_valid_from has datatype time, date_valid_to has datatype time, other_card_details has datatype text which has card_id and Given the Table financial transactions having columns as transaction_id has datatype number, previous_transaction_id has datatype number, account_id has datatype number, card_id has datatype number, transaction_type has datatype text, transaction_date has datatype time, transaction_amount has datatype number, transaction_comment has datatype text, other_transaction_details has datatype text which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. What are the ids and first names of customers who do not hold a credit card?
SELECT DISTINCT card_type_code FROM Customers_Cards
Given the Table accounts having columns as account_id has datatype number, customer_id has datatype number, account_name has datatype text, other_account_details has datatype text which has account_id and Given the Table customers having columns as customer_id has datatype number, customer_first_name has datatype text, customer_last_name has datatype text, customer_address has datatype text, customer_phone has datatype text, customer_email has datatype text, other_customer_details has datatype text which has customer_id and Given the Table customers cards having columns as card_id has datatype number, customer_id has datatype number, card_type_code has datatype text, card_number has datatype text, date_valid_from has datatype time, date_valid_to has datatype time, other_card_details has datatype text which has card_id and Given the Table financial transactions having columns as transaction_id has datatype number, previous_transaction_id has datatype number, account_id has datatype number, card_id has datatype number, transaction_type has datatype text, transaction_date has datatype time, transaction_amount has datatype number, transaction_comment has datatype text, other_transaction_details has datatype text which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. Show all card type codes.
SELECT DISTINCT card_type_code FROM Customers_Cards
Given the Table accounts having columns as account_id has datatype number, customer_id has datatype number, account_name has datatype text, other_account_details has datatype text which has account_id and Given the Table customers having columns as customer_id has datatype number, customer_first_name has datatype text, customer_last_name has datatype text, customer_address has datatype text, customer_phone has datatype text, customer_email has datatype text, other_customer_details has datatype text which has customer_id and Given the Table customers cards having columns as card_id has datatype number, customer_id has datatype number, card_type_code has datatype text, card_number has datatype text, date_valid_from has datatype time, date_valid_to has datatype time, other_card_details has datatype text which has card_id and Given the Table financial transactions having columns as transaction_id has datatype number, previous_transaction_id has datatype number, account_id has datatype number, card_id has datatype number, transaction_type has datatype text, transaction_date has datatype time, transaction_amount has datatype number, transaction_comment has datatype text, other_transaction_details has datatype text which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. What are the different card type codes?
SELECT count(DISTINCT card_type_code) FROM Customers_Cards
Given the Table accounts having columns as account_id has datatype number, customer_id has datatype number, account_name has datatype text, other_account_details has datatype text which has account_id and Given the Table customers having columns as customer_id has datatype number, customer_first_name has datatype text, customer_last_name has datatype text, customer_address has datatype text, customer_phone has datatype text, customer_email has datatype text, other_customer_details has datatype text which has customer_id and Given the Table customers cards having columns as card_id has datatype number, customer_id has datatype number, card_type_code has datatype text, card_number has datatype text, date_valid_from has datatype time, date_valid_to has datatype time, other_card_details has datatype text which has card_id and Given the Table financial transactions having columns as transaction_id has datatype number, previous_transaction_id has datatype number, account_id has datatype number, card_id has datatype number, transaction_type has datatype text, transaction_date has datatype time, transaction_amount has datatype number, transaction_comment has datatype text, other_transaction_details has datatype text which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. Show the number of card types.
SELECT count(DISTINCT card_type_code) FROM Customers_Cards
Given the Table accounts having columns as account_id has datatype number, customer_id has datatype number, account_name has datatype text, other_account_details has datatype text which has account_id and Given the Table customers having columns as customer_id has datatype number, customer_first_name has datatype text, customer_last_name has datatype text, customer_address has datatype text, customer_phone has datatype text, customer_email has datatype text, other_customer_details has datatype text which has customer_id and Given the Table customers cards having columns as card_id has datatype number, customer_id has datatype number, card_type_code has datatype text, card_number has datatype text, date_valid_from has datatype time, date_valid_to has datatype time, other_card_details has datatype text which has card_id and Given the Table financial transactions having columns as transaction_id has datatype number, previous_transaction_id has datatype number, account_id has datatype number, card_id has datatype number, transaction_type has datatype text, transaction_date has datatype time, transaction_amount has datatype number, transaction_comment has datatype text, other_transaction_details has datatype text which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. How many different card types are there?
SELECT DISTINCT transaction_type FROM Financial_Transactions
Given the Table accounts having columns as account_id has datatype number, customer_id has datatype number, account_name has datatype text, other_account_details has datatype text which has account_id and Given the Table customers having columns as customer_id has datatype number, customer_first_name has datatype text, customer_last_name has datatype text, customer_address has datatype text, customer_phone has datatype text, customer_email has datatype text, other_customer_details has datatype text which has customer_id and Given the Table customers cards having columns as card_id has datatype number, customer_id has datatype number, card_type_code has datatype text, card_number has datatype text, date_valid_from has datatype time, date_valid_to has datatype time, other_card_details has datatype text which has card_id and Given the Table financial transactions having columns as transaction_id has datatype number, previous_transaction_id has datatype number, account_id has datatype number, card_id has datatype number, transaction_type has datatype text, transaction_date has datatype time, transaction_amount has datatype number, transaction_comment has datatype text, other_transaction_details has datatype text which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. Show all transaction types.
SELECT DISTINCT transaction_type FROM Financial_Transactions
Given the Table accounts having columns as account_id has datatype number, customer_id has datatype number, account_name has datatype text, other_account_details has datatype text which has account_id and Given the Table customers having columns as customer_id has datatype number, customer_first_name has datatype text, customer_last_name has datatype text, customer_address has datatype text, customer_phone has datatype text, customer_email has datatype text, other_customer_details has datatype text which has customer_id and Given the Table customers cards having columns as card_id has datatype number, customer_id has datatype number, card_type_code has datatype text, card_number has datatype text, date_valid_from has datatype time, date_valid_to has datatype time, other_card_details has datatype text which has card_id and Given the Table financial transactions having columns as transaction_id has datatype number, previous_transaction_id has datatype number, account_id has datatype number, card_id has datatype number, transaction_type has datatype text, transaction_date has datatype time, transaction_amount has datatype number, transaction_comment has datatype text, other_transaction_details has datatype text which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. What are the different types of transactions?
SELECT count(DISTINCT transaction_type) FROM Financial_Transactions
Given the Table accounts having columns as account_id has datatype number, customer_id has datatype number, account_name has datatype text, other_account_details has datatype text which has account_id and Given the Table customers having columns as customer_id has datatype number, customer_first_name has datatype text, customer_last_name has datatype text, customer_address has datatype text, customer_phone has datatype text, customer_email has datatype text, other_customer_details has datatype text which has customer_id and Given the Table customers cards having columns as card_id has datatype number, customer_id has datatype number, card_type_code has datatype text, card_number has datatype text, date_valid_from has datatype time, date_valid_to has datatype time, other_card_details has datatype text which has card_id and Given the Table financial transactions having columns as transaction_id has datatype number, previous_transaction_id has datatype number, account_id has datatype number, card_id has datatype number, transaction_type has datatype text, transaction_date has datatype time, transaction_amount has datatype number, transaction_comment has datatype text, other_transaction_details has datatype text which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. Show the number of transaction types.
SELECT count(DISTINCT transaction_type) FROM Financial_Transactions
Given the Table accounts having columns as account_id has datatype number, customer_id has datatype number, account_name has datatype text, other_account_details has datatype text which has account_id and Given the Table customers having columns as customer_id has datatype number, customer_first_name has datatype text, customer_last_name has datatype text, customer_address has datatype text, customer_phone has datatype text, customer_email has datatype text, other_customer_details has datatype text which has customer_id and Given the Table customers cards having columns as card_id has datatype number, customer_id has datatype number, card_type_code has datatype text, card_number has datatype text, date_valid_from has datatype time, date_valid_to has datatype time, other_card_details has datatype text which has card_id and Given the Table financial transactions having columns as transaction_id has datatype number, previous_transaction_id has datatype number, account_id has datatype number, card_id has datatype number, transaction_type has datatype text, transaction_date has datatype time, transaction_amount has datatype number, transaction_comment has datatype text, other_transaction_details has datatype text which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. How many different types of transactions are there?
SELECT avg(transaction_amount) , sum(transaction_amount) FROM Financial_transactions
Given the Table accounts having columns as account_id has datatype number, customer_id has datatype number, account_name has datatype text, other_account_details has datatype text which has account_id and Given the Table customers having columns as customer_id has datatype number, customer_first_name has datatype text, customer_last_name has datatype text, customer_address has datatype text, customer_phone has datatype text, customer_email has datatype text, other_customer_details has datatype text which has customer_id and Given the Table customers cards having columns as card_id has datatype number, customer_id has datatype number, card_type_code has datatype text, card_number has datatype text, date_valid_from has datatype time, date_valid_to has datatype time, other_card_details has datatype text which has card_id and Given the Table financial transactions having columns as transaction_id has datatype number, previous_transaction_id has datatype number, account_id has datatype number, card_id has datatype number, transaction_type has datatype text, transaction_date has datatype time, transaction_amount has datatype number, transaction_comment has datatype text, other_transaction_details has datatype text which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. What is the average and total transaction amount?
SELECT avg(transaction_amount) , sum(transaction_amount) FROM Financial_transactions
Given the Table accounts having columns as account_id has datatype number, customer_id has datatype number, account_name has datatype text, other_account_details has datatype text which has account_id and Given the Table customers having columns as customer_id has datatype number, customer_first_name has datatype text, customer_last_name has datatype text, customer_address has datatype text, customer_phone has datatype text, customer_email has datatype text, other_customer_details has datatype text which has customer_id and Given the Table customers cards having columns as card_id has datatype number, customer_id has datatype number, card_type_code has datatype text, card_number has datatype text, date_valid_from has datatype time, date_valid_to has datatype time, other_card_details has datatype text which has card_id and Given the Table financial transactions having columns as transaction_id has datatype number, previous_transaction_id has datatype number, account_id has datatype number, card_id has datatype number, transaction_type has datatype text, transaction_date has datatype time, transaction_amount has datatype number, transaction_comment has datatype text, other_transaction_details has datatype text which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. Return the average transaction amount, as well as the total amount of all transactions.
SELECT T2.card_type_code , count(*) FROM Financial_transactions AS T1 JOIN Customers_cards AS T2 ON T1.card_id = T2.card_id GROUP BY T2.card_type_code
Given the Table accounts having columns as account_id has datatype number, customer_id has datatype number, account_name has datatype text, other_account_details has datatype text which has account_id and Given the Table customers having columns as customer_id has datatype number, customer_first_name has datatype text, customer_last_name has datatype text, customer_address has datatype text, customer_phone has datatype text, customer_email has datatype text, other_customer_details has datatype text which has customer_id and Given the Table customers cards having columns as card_id has datatype number, customer_id has datatype number, card_type_code has datatype text, card_number has datatype text, date_valid_from has datatype time, date_valid_to has datatype time, other_card_details has datatype text which has card_id and Given the Table financial transactions having columns as transaction_id has datatype number, previous_transaction_id has datatype number, account_id has datatype number, card_id has datatype number, transaction_type has datatype text, transaction_date has datatype time, transaction_amount has datatype number, transaction_comment has datatype text, other_transaction_details has datatype text which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. Show the card type codes and the number of transactions.
SELECT T2.card_type_code , count(*) FROM Financial_transactions AS T1 JOIN Customers_cards AS T2 ON T1.card_id = T2.card_id GROUP BY T2.card_type_code
Given the Table accounts having columns as account_id has datatype number, customer_id has datatype number, account_name has datatype text, other_account_details has datatype text which has account_id and Given the Table customers having columns as customer_id has datatype number, customer_first_name has datatype text, customer_last_name has datatype text, customer_address has datatype text, customer_phone has datatype text, customer_email has datatype text, other_customer_details has datatype text which has customer_id and Given the Table customers cards having columns as card_id has datatype number, customer_id has datatype number, card_type_code has datatype text, card_number has datatype text, date_valid_from has datatype time, date_valid_to has datatype time, other_card_details has datatype text which has card_id and Given the Table financial transactions having columns as transaction_id has datatype number, previous_transaction_id has datatype number, account_id has datatype number, card_id has datatype number, transaction_type has datatype text, transaction_date has datatype time, transaction_amount has datatype number, transaction_comment has datatype text, other_transaction_details has datatype text which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. What are the different card types, and how many transactions have been made with each?
SELECT transaction_type , count(*) FROM Financial_transactions GROUP BY transaction_type
Given the Table accounts having columns as account_id has datatype number, customer_id has datatype number, account_name has datatype text, other_account_details has datatype text which has account_id and Given the Table customers having columns as customer_id has datatype number, customer_first_name has datatype text, customer_last_name has datatype text, customer_address has datatype text, customer_phone has datatype text, customer_email has datatype text, other_customer_details has datatype text which has customer_id and Given the Table customers cards having columns as card_id has datatype number, customer_id has datatype number, card_type_code has datatype text, card_number has datatype text, date_valid_from has datatype time, date_valid_to has datatype time, other_card_details has datatype text which has card_id and Given the Table financial transactions having columns as transaction_id has datatype number, previous_transaction_id has datatype number, account_id has datatype number, card_id has datatype number, transaction_type has datatype text, transaction_date has datatype time, transaction_amount has datatype number, transaction_comment has datatype text, other_transaction_details has datatype text which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. Show the transaction type and the number of transactions.
SELECT transaction_type , count(*) FROM Financial_transactions GROUP BY transaction_type
Given the Table accounts having columns as account_id has datatype number, customer_id has datatype number, account_name has datatype text, other_account_details has datatype text which has account_id and Given the Table customers having columns as customer_id has datatype number, customer_first_name has datatype text, customer_last_name has datatype text, customer_address has datatype text, customer_phone has datatype text, customer_email has datatype text, other_customer_details has datatype text which has customer_id and Given the Table customers cards having columns as card_id has datatype number, customer_id has datatype number, card_type_code has datatype text, card_number has datatype text, date_valid_from has datatype time, date_valid_to has datatype time, other_card_details has datatype text which has card_id and Given the Table financial transactions having columns as transaction_id has datatype number, previous_transaction_id has datatype number, account_id has datatype number, card_id has datatype number, transaction_type has datatype text, transaction_date has datatype time, transaction_amount has datatype number, transaction_comment has datatype text, other_transaction_details has datatype text which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. What are the different transaction types, and how many transactions of each have taken place?
SELECT transaction_type FROM Financial_transactions GROUP BY transaction_type ORDER BY sum(transaction_amount) DESC LIMIT 1
Given the Table accounts having columns as account_id has datatype number, customer_id has datatype number, account_name has datatype text, other_account_details has datatype text which has account_id and Given the Table customers having columns as customer_id has datatype number, customer_first_name has datatype text, customer_last_name has datatype text, customer_address has datatype text, customer_phone has datatype text, customer_email has datatype text, other_customer_details has datatype text which has customer_id and Given the Table customers cards having columns as card_id has datatype number, customer_id has datatype number, card_type_code has datatype text, card_number has datatype text, date_valid_from has datatype time, date_valid_to has datatype time, other_card_details has datatype text which has card_id and Given the Table financial transactions having columns as transaction_id has datatype number, previous_transaction_id has datatype number, account_id has datatype number, card_id has datatype number, transaction_type has datatype text, transaction_date has datatype time, transaction_amount has datatype number, transaction_comment has datatype text, other_transaction_details has datatype text which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. What is the transaction type that has processed the greatest total amount in transactions?
SELECT transaction_type FROM Financial_transactions GROUP BY transaction_type ORDER BY sum(transaction_amount) DESC LIMIT 1
Given the Table accounts having columns as account_id has datatype number, customer_id has datatype number, account_name has datatype text, other_account_details has datatype text which has account_id and Given the Table customers having columns as customer_id has datatype number, customer_first_name has datatype text, customer_last_name has datatype text, customer_address has datatype text, customer_phone has datatype text, customer_email has datatype text, other_customer_details has datatype text which has customer_id and Given the Table customers cards having columns as card_id has datatype number, customer_id has datatype number, card_type_code has datatype text, card_number has datatype text, date_valid_from has datatype time, date_valid_to has datatype time, other_card_details has datatype text which has card_id and Given the Table financial transactions having columns as transaction_id has datatype number, previous_transaction_id has datatype number, account_id has datatype number, card_id has datatype number, transaction_type has datatype text, transaction_date has datatype time, transaction_amount has datatype number, transaction_comment has datatype text, other_transaction_details has datatype text which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. Return the type of transaction with the highest total amount.
SELECT account_id , count(*) FROM Financial_transactions GROUP BY account_id
Given the Table accounts having columns as account_id has datatype number, customer_id has datatype number, account_name has datatype text, other_account_details has datatype text which has account_id and Given the Table customers having columns as customer_id has datatype number, customer_first_name has datatype text, customer_last_name has datatype text, customer_address has datatype text, customer_phone has datatype text, customer_email has datatype text, other_customer_details has datatype text which has customer_id and Given the Table customers cards having columns as card_id has datatype number, customer_id has datatype number, card_type_code has datatype text, card_number has datatype text, date_valid_from has datatype time, date_valid_to has datatype time, other_card_details has datatype text which has card_id and Given the Table financial transactions having columns as transaction_id has datatype number, previous_transaction_id has datatype number, account_id has datatype number, card_id has datatype number, transaction_type has datatype text, transaction_date has datatype time, transaction_amount has datatype number, transaction_comment has datatype text, other_transaction_details has datatype text which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. Show the account id and the number of transactions for each account
SELECT account_id , count(*) FROM Financial_transactions GROUP BY account_id
Given the Table accounts having columns as account_id has datatype number, customer_id has datatype number, account_name has datatype text, other_account_details has datatype text which has account_id and Given the Table customers having columns as customer_id has datatype number, customer_first_name has datatype text, customer_last_name has datatype text, customer_address has datatype text, customer_phone has datatype text, customer_email has datatype text, other_customer_details has datatype text which has customer_id and Given the Table customers cards having columns as card_id has datatype number, customer_id has datatype number, card_type_code has datatype text, card_number has datatype text, date_valid_from has datatype time, date_valid_to has datatype time, other_card_details has datatype text which has card_id and Given the Table financial transactions having columns as transaction_id has datatype number, previous_transaction_id has datatype number, account_id has datatype number, card_id has datatype number, transaction_type has datatype text, transaction_date has datatype time, transaction_amount has datatype number, transaction_comment has datatype text, other_transaction_details has datatype text which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. What are the different account ids that have made financial transactions, as well as how many transactions correspond to each?
SELECT count(*) FROM track
Given the Table race having columns as Race_ID has datatype number, Name has datatype text, Class has datatype text, Date has datatype text, Track_ID has datatype text which has Race_ID and Given the Table track having columns as Track_ID has datatype number, Name has datatype text, Location has datatype text, Seating has datatype number, Year_Opened has datatype number which has Track_ID. Answer the question by writing the appropriate SQL code. How many tracks do we have?
SELECT count(*) FROM track
Given the Table race having columns as Race_ID has datatype number, Name has datatype text, Class has datatype text, Date has datatype text, Track_ID has datatype text which has Race_ID and Given the Table track having columns as Track_ID has datatype number, Name has datatype text, Location has datatype text, Seating has datatype number, Year_Opened has datatype number which has Track_ID. Answer the question by writing the appropriate SQL code. Count the number of tracks.
SELECT name , LOCATION FROM track
Given the Table race having columns as Race_ID has datatype number, Name has datatype text, Class has datatype text, Date has datatype text, Track_ID has datatype text which has Race_ID and Given the Table track having columns as Track_ID has datatype number, Name has datatype text, Location has datatype text, Seating has datatype number, Year_Opened has datatype number which has Track_ID. Answer the question by writing the appropriate SQL code. Show the name and location for all tracks.
SELECT name , LOCATION FROM track
Given the Table race having columns as Race_ID has datatype number, Name has datatype text, Class has datatype text, Date has datatype text, Track_ID has datatype text which has Race_ID and Given the Table track having columns as Track_ID has datatype number, Name has datatype text, Location has datatype text, Seating has datatype number, Year_Opened has datatype number which has Track_ID. Answer the question by writing the appropriate SQL code. What are the names and locations of all tracks?
SELECT name , seating FROM track WHERE year_opened > 2000 ORDER BY seating
Given the Table race having columns as Race_ID has datatype number, Name has datatype text, Class has datatype text, Date has datatype text, Track_ID has datatype text which has Race_ID and Given the Table track having columns as Track_ID has datatype number, Name has datatype text, Location has datatype text, Seating has datatype number, Year_Opened has datatype number which has Track_ID. Answer the question by writing the appropriate SQL code. Show names and seatings, ordered by seating for all tracks opened after 2000.
SELECT name , seating FROM track WHERE year_opened > 2000 ORDER BY seating
Given the Table race having columns as Race_ID has datatype number, Name has datatype text, Class has datatype text, Date has datatype text, Track_ID has datatype text which has Race_ID and Given the Table track having columns as Track_ID has datatype number, Name has datatype text, Location has datatype text, Seating has datatype number, Year_Opened has datatype number which has Track_ID. Answer the question by writing the appropriate SQL code. What are the names and seatings for all tracks opened after 2000, ordered by seating?
SELECT name , LOCATION , seating FROM track ORDER BY year_opened DESC LIMIT 1
Given the Table race having columns as Race_ID has datatype number, Name has datatype text, Class has datatype text, Date has datatype text, Track_ID has datatype text which has Race_ID and Given the Table track having columns as Track_ID has datatype number, Name has datatype text, Location has datatype text, Seating has datatype number, Year_Opened has datatype number which has Track_ID. Answer the question by writing the appropriate SQL code. What is the name, location and seating for the most recently opened track?
SELECT name , LOCATION , seating FROM track ORDER BY year_opened DESC LIMIT 1
Given the Table race having columns as Race_ID has datatype number, Name has datatype text, Class has datatype text, Date has datatype text, Track_ID has datatype text which has Race_ID and Given the Table track having columns as Track_ID has datatype number, Name has datatype text, Location has datatype text, Seating has datatype number, Year_Opened has datatype number which has Track_ID. Answer the question by writing the appropriate SQL code. Return the name, location, and seating of the track that was opened in the most recent year.
SELECT min(seating) , max(seating) , avg(seating) FROM track
Given the Table race having columns as Race_ID has datatype number, Name has datatype text, Class has datatype text, Date has datatype text, Track_ID has datatype text which has Race_ID and Given the Table track having columns as Track_ID has datatype number, Name has datatype text, Location has datatype text, Seating has datatype number, Year_Opened has datatype number which has Track_ID. Answer the question by writing the appropriate SQL code. What is the minimum, maximum, and average seating for all tracks.
SELECT min(seating) , max(seating) , avg(seating) FROM track
Given the Table race having columns as Race_ID has datatype number, Name has datatype text, Class has datatype text, Date has datatype text, Track_ID has datatype text which has Race_ID and Given the Table track having columns as Track_ID has datatype number, Name has datatype text, Location has datatype text, Seating has datatype number, Year_Opened has datatype number which has Track_ID. Answer the question by writing the appropriate SQL code. Return the minimum, maximum, and average seating across all tracks.
SELECT name , LOCATION , year_opened FROM track WHERE seating > (SELECT avg(seating) FROM track)
Given the Table race having columns as Race_ID has datatype number, Name has datatype text, Class has datatype text, Date has datatype text, Track_ID has datatype text which has Race_ID and Given the Table track having columns as Track_ID has datatype number, Name has datatype text, Location has datatype text, Seating has datatype number, Year_Opened has datatype number which has Track_ID. Answer the question by writing the appropriate SQL code. Show the name, location, open year for all tracks with a seating higher than the average.
SELECT name , LOCATION , year_opened FROM track WHERE seating > (SELECT avg(seating) FROM track)
Given the Table race having columns as Race_ID has datatype number, Name has datatype text, Class has datatype text, Date has datatype text, Track_ID has datatype text which has Race_ID and Given the Table track having columns as Track_ID has datatype number, Name has datatype text, Location has datatype text, Seating has datatype number, Year_Opened has datatype number which has Track_ID. Answer the question by writing the appropriate SQL code. What are the names, locations, and years of opening for tracks with seating higher than average?
SELECT DISTINCT LOCATION FROM track
Given the Table race having columns as Race_ID has datatype number, Name has datatype text, Class has datatype text, Date has datatype text, Track_ID has datatype text which has Race_ID and Given the Table track having columns as Track_ID has datatype number, Name has datatype text, Location has datatype text, Seating has datatype number, Year_Opened has datatype number which has Track_ID. Answer the question by writing the appropriate SQL code. What are distinct locations where tracks are located?
SELECT DISTINCT LOCATION FROM track
Given the Table race having columns as Race_ID has datatype number, Name has datatype text, Class has datatype text, Date has datatype text, Track_ID has datatype text which has Race_ID and Given the Table track having columns as Track_ID has datatype number, Name has datatype text, Location has datatype text, Seating has datatype number, Year_Opened has datatype number which has Track_ID. Answer the question by writing the appropriate SQL code. Give the different locations of tracks.
SELECT count(*) FROM race
Given the Table race having columns as Race_ID has datatype number, Name has datatype text, Class has datatype text, Date has datatype text, Track_ID has datatype text which has Race_ID and Given the Table track having columns as Track_ID has datatype number, Name has datatype text, Location has datatype text, Seating has datatype number, Year_Opened has datatype number which has Track_ID. Answer the question by writing the appropriate SQL code. How many races are there?
SELECT count(*) FROM race
Given the Table race having columns as Race_ID has datatype number, Name has datatype text, Class has datatype text, Date has datatype text, Track_ID has datatype text which has Race_ID and Given the Table track having columns as Track_ID has datatype number, Name has datatype text, Location has datatype text, Seating has datatype number, Year_Opened has datatype number which has Track_ID. Answer the question by writing the appropriate SQL code. Count the number of races.
SELECT DISTINCT CLASS FROM race
Given the Table race having columns as Race_ID has datatype number, Name has datatype text, Class has datatype text, Date has datatype text, Track_ID has datatype text which has Race_ID and Given the Table track having columns as Track_ID has datatype number, Name has datatype text, Location has datatype text, Seating has datatype number, Year_Opened has datatype number which has Track_ID. Answer the question by writing the appropriate SQL code. What are the distinct classes that races can have?
SELECT DISTINCT CLASS FROM race
Given the Table race having columns as Race_ID has datatype number, Name has datatype text, Class has datatype text, Date has datatype text, Track_ID has datatype text which has Race_ID and Given the Table track having columns as Track_ID has datatype number, Name has datatype text, Location has datatype text, Seating has datatype number, Year_Opened has datatype number which has Track_ID. Answer the question by writing the appropriate SQL code. Return the different classes of races.
SELECT name , CLASS , date FROM race
Given the Table race having columns as Race_ID has datatype number, Name has datatype text, Class has datatype text, Date has datatype text, Track_ID has datatype text which has Race_ID and Given the Table track having columns as Track_ID has datatype number, Name has datatype text, Location has datatype text, Seating has datatype number, Year_Opened has datatype number which has Track_ID. Answer the question by writing the appropriate SQL code. Show name, class, and date for all races.
SELECT name , CLASS , date FROM race
Given the Table race having columns as Race_ID has datatype number, Name has datatype text, Class has datatype text, Date has datatype text, Track_ID has datatype text which has Race_ID and Given the Table track having columns as Track_ID has datatype number, Name has datatype text, Location has datatype text, Seating has datatype number, Year_Opened has datatype number which has Track_ID. Answer the question by writing the appropriate SQL code. What are the names, classes, and dates for all races?
SELECT CLASS , count(*) FROM race GROUP BY CLASS
Given the Table race having columns as Race_ID has datatype number, Name has datatype text, Class has datatype text, Date has datatype text, Track_ID has datatype text which has Race_ID and Given the Table track having columns as Track_ID has datatype number, Name has datatype text, Location has datatype text, Seating has datatype number, Year_Opened has datatype number which has Track_ID. Answer the question by writing the appropriate SQL code. Show the race class and number of races in each class.
SELECT CLASS , count(*) FROM race GROUP BY CLASS
Given the Table race having columns as Race_ID has datatype number, Name has datatype text, Class has datatype text, Date has datatype text, Track_ID has datatype text which has Race_ID and Given the Table track having columns as Track_ID has datatype number, Name has datatype text, Location has datatype text, Seating has datatype number, Year_Opened has datatype number which has Track_ID. Answer the question by writing the appropriate SQL code. What are the different classes of races, and how many races correspond to each?
SELECT CLASS FROM race GROUP BY CLASS ORDER BY count(*) DESC LIMIT 1
Given the Table race having columns as Race_ID has datatype number, Name has datatype text, Class has datatype text, Date has datatype text, Track_ID has datatype text which has Race_ID and Given the Table track having columns as Track_ID has datatype number, Name has datatype text, Location has datatype text, Seating has datatype number, Year_Opened has datatype number which has Track_ID. Answer the question by writing the appropriate SQL code. What is the race class with most number of races.
SELECT CLASS FROM race GROUP BY CLASS ORDER BY count(*) DESC LIMIT 1
Given the Table race having columns as Race_ID has datatype number, Name has datatype text, Class has datatype text, Date has datatype text, Track_ID has datatype text which has Race_ID and Given the Table track having columns as Track_ID has datatype number, Name has datatype text, Location has datatype text, Seating has datatype number, Year_Opened has datatype number which has Track_ID. Answer the question by writing the appropriate SQL code. Give the class of races that is most common.
SELECT CLASS FROM race GROUP BY CLASS HAVING count(*) >= 2
Given the Table race having columns as Race_ID has datatype number, Name has datatype text, Class has datatype text, Date has datatype text, Track_ID has datatype text which has Race_ID and Given the Table track having columns as Track_ID has datatype number, Name has datatype text, Location has datatype text, Seating has datatype number, Year_Opened has datatype number which has Track_ID. Answer the question by writing the appropriate SQL code. List the race class with at least two races.
SELECT CLASS FROM race GROUP BY CLASS HAVING count(*) >= 2
Given the Table race having columns as Race_ID has datatype number, Name has datatype text, Class has datatype text, Date has datatype text, Track_ID has datatype text which has Race_ID and Given the Table track having columns as Track_ID has datatype number, Name has datatype text, Location has datatype text, Seating has datatype number, Year_Opened has datatype number which has Track_ID. Answer the question by writing the appropriate SQL code. What are the classes of races that have two or more corresponding races?
SELECT name FROM track EXCEPT SELECT T2.name FROM race AS T1 JOIN track AS T2 ON T1.track_id = T2.track_id WHERE T1.class = 'GT'
Given the Table race having columns as Race_ID has datatype number, Name has datatype text, Class has datatype text, Date has datatype text, Track_ID has datatype text which has Race_ID and Given the Table track having columns as Track_ID has datatype number, Name has datatype text, Location has datatype text, Seating has datatype number, Year_Opened has datatype number which has Track_ID. Answer the question by writing the appropriate SQL code. What are the names for tracks without a race in class 'GT'.
SELECT name FROM track EXCEPT SELECT T2.name FROM race AS T1 JOIN track AS T2 ON T1.track_id = T2.track_id WHERE T1.class = 'GT'
Given the Table race having columns as Race_ID has datatype number, Name has datatype text, Class has datatype text, Date has datatype text, Track_ID has datatype text which has Race_ID and Given the Table track having columns as Track_ID has datatype number, Name has datatype text, Location has datatype text, Seating has datatype number, Year_Opened has datatype number which has Track_ID. Answer the question by writing the appropriate SQL code. Give the names of tracks that do not have a race in the class 'GT'.
SELECT name FROM track WHERE track_id NOT IN (SELECT track_id FROM race)
Given the Table race having columns as Race_ID has datatype number, Name has datatype text, Class has datatype text, Date has datatype text, Track_ID has datatype text which has Race_ID and Given the Table track having columns as Track_ID has datatype number, Name has datatype text, Location has datatype text, Seating has datatype number, Year_Opened has datatype number which has Track_ID. Answer the question by writing the appropriate SQL code. Show all track names that have had no races.
SELECT name FROM track WHERE track_id NOT IN (SELECT track_id FROM race)
Given the Table race having columns as Race_ID has datatype number, Name has datatype text, Class has datatype text, Date has datatype text, Track_ID has datatype text which has Race_ID and Given the Table track having columns as Track_ID has datatype number, Name has datatype text, Location has datatype text, Seating has datatype number, Year_Opened has datatype number which has Track_ID. Answer the question by writing the appropriate SQL code. Return the names of tracks that have no had any races.
SELECT year_opened FROM track WHERE seating BETWEEN 4000 AND 5000
Given the Table race having columns as Race_ID has datatype number, Name has datatype text, Class has datatype text, Date has datatype text, Track_ID has datatype text which has Race_ID and Given the Table track having columns as Track_ID has datatype number, Name has datatype text, Location has datatype text, Seating has datatype number, Year_Opened has datatype number which has Track_ID. Answer the question by writing the appropriate SQL code. Show year where a track with a seating at least 5000 opened and a track with seating no more than 4000 opened.
SELECT year_opened FROM track WHERE seating BETWEEN 4000 AND 5000
Given the Table race having columns as Race_ID has datatype number, Name has datatype text, Class has datatype text, Date has datatype text, Track_ID has datatype text which has Race_ID and Given the Table track having columns as Track_ID has datatype number, Name has datatype text, Location has datatype text, Seating has datatype number, Year_Opened has datatype number which has Track_ID. Answer the question by writing the appropriate SQL code. What are the years of opening for tracks with seating between 4000 and 5000?
SELECT T2.name , count(*) FROM race AS T1 JOIN track AS T2 ON T1.track_id = T2.track_id GROUP BY T1.track_id
Given the Table race having columns as Race_ID has datatype number, Name has datatype text, Class has datatype text, Date has datatype text, Track_ID has datatype text which has Race_ID and Given the Table track having columns as Track_ID has datatype number, Name has datatype text, Location has datatype text, Seating has datatype number, Year_Opened has datatype number which has Track_ID. Answer the question by writing the appropriate SQL code. Show the name of track and the number of races in each track.
SELECT T2.name , count(*) FROM race AS T1 JOIN track AS T2 ON T1.track_id = T2.track_id GROUP BY T1.track_id
Given the Table race having columns as Race_ID has datatype number, Name has datatype text, Class has datatype text, Date has datatype text, Track_ID has datatype text which has Race_ID and Given the Table track having columns as Track_ID has datatype number, Name has datatype text, Location has datatype text, Seating has datatype number, Year_Opened has datatype number which has Track_ID. Answer the question by writing the appropriate SQL code. What are the names of different tracks, and how many races has each had?
SELECT T2.name FROM race AS T1 JOIN track AS T2 ON T1.track_id = T2.track_id GROUP BY T1.track_id ORDER BY count(*) DESC LIMIT 1
Given the Table race having columns as Race_ID has datatype number, Name has datatype text, Class has datatype text, Date has datatype text, Track_ID has datatype text which has Race_ID and Given the Table track having columns as Track_ID has datatype number, Name has datatype text, Location has datatype text, Seating has datatype number, Year_Opened has datatype number which has Track_ID. Answer the question by writing the appropriate SQL code. Show the name of track with most number of races.
SELECT T2.name FROM race AS T1 JOIN track AS T2 ON T1.track_id = T2.track_id GROUP BY T1.track_id ORDER BY count(*) DESC LIMIT 1
Given the Table race having columns as Race_ID has datatype number, Name has datatype text, Class has datatype text, Date has datatype text, Track_ID has datatype text which has Race_ID and Given the Table track having columns as Track_ID has datatype number, Name has datatype text, Location has datatype text, Seating has datatype number, Year_Opened has datatype number which has Track_ID. Answer the question by writing the appropriate SQL code. What is the name of the track that has had the greatest number of races?
SELECT T1.name , T1.date , T2.name FROM race AS T1 JOIN track AS T2 ON T1.track_id = T2.track_id
Given the Table race having columns as Race_ID has datatype number, Name has datatype text, Class has datatype text, Date has datatype text, Track_ID has datatype text which has Race_ID and Given the Table track having columns as Track_ID has datatype number, Name has datatype text, Location has datatype text, Seating has datatype number, Year_Opened has datatype number which has Track_ID. Answer the question by writing the appropriate SQL code. Show the name and date for each race and its track name.
SELECT T1.name , T1.date , T2.name FROM race AS T1 JOIN track AS T2 ON T1.track_id = T2.track_id
Given the Table race having columns as Race_ID has datatype number, Name has datatype text, Class has datatype text, Date has datatype text, Track_ID has datatype text which has Race_ID and Given the Table track having columns as Track_ID has datatype number, Name has datatype text, Location has datatype text, Seating has datatype number, Year_Opened has datatype number which has Track_ID. Answer the question by writing the appropriate SQL code. What are the names and dates of races, and the names of the tracks where they are held?
SELECT T2.name , T2.location FROM race AS T1 JOIN track AS T2 ON T1.track_id = T2.track_id GROUP BY T1.track_id HAVING count(*) = 1
Given the Table race having columns as Race_ID has datatype number, Name has datatype text, Class has datatype text, Date has datatype text, Track_ID has datatype text which has Race_ID and Given the Table track having columns as Track_ID has datatype number, Name has datatype text, Location has datatype text, Seating has datatype number, Year_Opened has datatype number which has Track_ID. Answer the question by writing the appropriate SQL code. Show the name and location of track with 1 race.
SELECT T2.name , T2.location FROM race AS T1 JOIN track AS T2 ON T1.track_id = T2.track_id GROUP BY T1.track_id HAVING count(*) = 1
Given the Table race having columns as Race_ID has datatype number, Name has datatype text, Class has datatype text, Date has datatype text, Track_ID has datatype text which has Race_ID and Given the Table track having columns as Track_ID has datatype number, Name has datatype text, Location has datatype text, Seating has datatype number, Year_Opened has datatype number which has Track_ID. Answer the question by writing the appropriate SQL code. What are the names and locations of tracks that have had exactly 1 race?
SELECT LOCATION FROM track WHERE seating > 90000 INTERSECT SELECT LOCATION FROM track WHERE seating < 70000
Given the Table race having columns as Race_ID has datatype number, Name has datatype text, Class has datatype text, Date has datatype text, Track_ID has datatype text which has Race_ID and Given the Table track having columns as Track_ID has datatype number, Name has datatype text, Location has datatype text, Seating has datatype number, Year_Opened has datatype number which has Track_ID. Answer the question by writing the appropriate SQL code. Find the locations where have both tracks with more than 90000 seats and tracks with less than 70000 seats.
SELECT LOCATION FROM track WHERE seating > 90000 INTERSECT SELECT LOCATION FROM track WHERE seating < 70000
Given the Table race having columns as Race_ID has datatype number, Name has datatype text, Class has datatype text, Date has datatype text, Track_ID has datatype text which has Race_ID and Given the Table track having columns as Track_ID has datatype number, Name has datatype text, Location has datatype text, Seating has datatype number, Year_Opened has datatype number which has Track_ID. Answer the question by writing the appropriate SQL code. What are the locations that have both tracks with more than 90000 seats, and tracks with fewer than 70000 seats?
SELECT count(*) FROM member WHERE Membership_card = 'Black'
Given the Table shop having columns as Shop_ID has datatype number, Address has datatype text, Num_of_staff has datatype text, Score has datatype number, Open_Year has datatype text which has Shop_ID and Given the Table member having columns as Member_ID has datatype number, Name has datatype text, Membership_card has datatype text, Age has datatype number, Time_of_purchase has datatype number, Level_of_membership has datatype number, Address has datatype text which has Member_ID and Given the Table happy hour having columns as HH_ID has datatype number, Shop_ID has datatype number, Month has datatype text, Num_of_shaff_in_charge has datatype number which has HH_ID and Given the Table happy hour member having columns as HH_ID has datatype number, Member_ID has datatype number, Total_amount has datatype number which has HH_ID. Answer the question by writing the appropriate SQL code. How many members have the black membership card?
SELECT count(*) , address FROM member GROUP BY address
Given the Table shop having columns as Shop_ID has datatype number, Address has datatype text, Num_of_staff has datatype text, Score has datatype number, Open_Year has datatype text which has Shop_ID and Given the Table member having columns as Member_ID has datatype number, Name has datatype text, Membership_card has datatype text, Age has datatype number, Time_of_purchase has datatype number, Level_of_membership has datatype number, Address has datatype text which has Member_ID and Given the Table happy hour having columns as HH_ID has datatype number, Shop_ID has datatype number, Month has datatype text, Num_of_shaff_in_charge has datatype number which has HH_ID and Given the Table happy hour member having columns as HH_ID has datatype number, Member_ID has datatype number, Total_amount has datatype number which has HH_ID. Answer the question by writing the appropriate SQL code. Find the number of members living in each address.
SELECT name FROM member WHERE address = 'Harford' OR address = 'Waterbury'
Given the Table shop having columns as Shop_ID has datatype number, Address has datatype text, Num_of_staff has datatype text, Score has datatype number, Open_Year has datatype text which has Shop_ID and Given the Table member having columns as Member_ID has datatype number, Name has datatype text, Membership_card has datatype text, Age has datatype number, Time_of_purchase has datatype number, Level_of_membership has datatype number, Address has datatype text which has Member_ID and Given the Table happy hour having columns as HH_ID has datatype number, Shop_ID has datatype number, Month has datatype text, Num_of_shaff_in_charge has datatype number which has HH_ID and Given the Table happy hour member having columns as HH_ID has datatype number, Member_ID has datatype number, Total_amount has datatype number which has HH_ID. Answer the question by writing the appropriate SQL code. Give me the names of members whose address is in Harford or Waterbury.
SELECT name , member_id FROM member WHERE Membership_card = 'Black' OR age < 30
Given the Table shop having columns as Shop_ID has datatype number, Address has datatype text, Num_of_staff has datatype text, Score has datatype number, Open_Year has datatype text which has Shop_ID and Given the Table member having columns as Member_ID has datatype number, Name has datatype text, Membership_card has datatype text, Age has datatype number, Time_of_purchase has datatype number, Level_of_membership has datatype number, Address has datatype text which has Member_ID and Given the Table happy hour having columns as HH_ID has datatype number, Shop_ID has datatype number, Month has datatype text, Num_of_shaff_in_charge has datatype number which has HH_ID and Given the Table happy hour member having columns as HH_ID has datatype number, Member_ID has datatype number, Total_amount has datatype number which has HH_ID. Answer the question by writing the appropriate SQL code. Find the ids and names of members who are under age 30 or with black membership card.
SELECT Time_of_purchase , age , address FROM member ORDER BY Time_of_purchase
Given the Table shop having columns as Shop_ID has datatype number, Address has datatype text, Num_of_staff has datatype text, Score has datatype number, Open_Year has datatype text which has Shop_ID and Given the Table member having columns as Member_ID has datatype number, Name has datatype text, Membership_card has datatype text, Age has datatype number, Time_of_purchase has datatype number, Level_of_membership has datatype number, Address has datatype text which has Member_ID and Given the Table happy hour having columns as HH_ID has datatype number, Shop_ID has datatype number, Month has datatype text, Num_of_shaff_in_charge has datatype number which has HH_ID and Given the Table happy hour member having columns as HH_ID has datatype number, Member_ID has datatype number, Total_amount has datatype number which has HH_ID. Answer the question by writing the appropriate SQL code. Find the purchase time, age and address of each member, and show the results in the order of purchase time.
SELECT Membership_card FROM member GROUP BY Membership_card HAVING count(*) > 5
Given the Table shop having columns as Shop_ID has datatype number, Address has datatype text, Num_of_staff has datatype text, Score has datatype number, Open_Year has datatype text which has Shop_ID and Given the Table member having columns as Member_ID has datatype number, Name has datatype text, Membership_card has datatype text, Age has datatype number, Time_of_purchase has datatype number, Level_of_membership has datatype number, Address has datatype text which has Member_ID and Given the Table happy hour having columns as HH_ID has datatype number, Shop_ID has datatype number, Month has datatype text, Num_of_shaff_in_charge has datatype number which has HH_ID and Given the Table happy hour member having columns as HH_ID has datatype number, Member_ID has datatype number, Total_amount has datatype number which has HH_ID. Answer the question by writing the appropriate SQL code. Which membership card has more than 5 members?
SELECT address FROM member WHERE age < 30 INTERSECT SELECT address FROM member WHERE age > 40
Given the Table shop having columns as Shop_ID has datatype number, Address has datatype text, Num_of_staff has datatype text, Score has datatype number, Open_Year has datatype text which has Shop_ID and Given the Table member having columns as Member_ID has datatype number, Name has datatype text, Membership_card has datatype text, Age has datatype number, Time_of_purchase has datatype number, Level_of_membership has datatype number, Address has datatype text which has Member_ID and Given the Table happy hour having columns as HH_ID has datatype number, Shop_ID has datatype number, Month has datatype text, Num_of_shaff_in_charge has datatype number which has HH_ID and Given the Table happy hour member having columns as HH_ID has datatype number, Member_ID has datatype number, Total_amount has datatype number which has HH_ID. Answer the question by writing the appropriate SQL code. Which address has both members younger than 30 and members older than 40?
SELECT membership_card FROM member WHERE address = 'Hartford' INTERSECT SELECT membership_card FROM member WHERE address = 'Waterbury'
Given the Table shop having columns as Shop_ID has datatype number, Address has datatype text, Num_of_staff has datatype text, Score has datatype number, Open_Year has datatype text which has Shop_ID and Given the Table member having columns as Member_ID has datatype number, Name has datatype text, Membership_card has datatype text, Age has datatype number, Time_of_purchase has datatype number, Level_of_membership has datatype number, Address has datatype text which has Member_ID and Given the Table happy hour having columns as HH_ID has datatype number, Shop_ID has datatype number, Month has datatype text, Num_of_shaff_in_charge has datatype number which has HH_ID and Given the Table happy hour member having columns as HH_ID has datatype number, Member_ID has datatype number, Total_amount has datatype number which has HH_ID. Answer the question by writing the appropriate SQL code. What is the membership card held by both members living in Hartford and ones living in Waterbury address?
SELECT count(*) FROM member WHERE address != 'Hartford'
Given the Table shop having columns as Shop_ID has datatype number, Address has datatype text, Num_of_staff has datatype text, Score has datatype number, Open_Year has datatype text which has Shop_ID and Given the Table member having columns as Member_ID has datatype number, Name has datatype text, Membership_card has datatype text, Age has datatype number, Time_of_purchase has datatype number, Level_of_membership has datatype number, Address has datatype text which has Member_ID and Given the Table happy hour having columns as HH_ID has datatype number, Shop_ID has datatype number, Month has datatype text, Num_of_shaff_in_charge has datatype number which has HH_ID and Given the Table happy hour member having columns as HH_ID has datatype number, Member_ID has datatype number, Total_amount has datatype number which has HH_ID. Answer the question by writing the appropriate SQL code. How many members are not living in Hartford?
SELECT address FROM member EXCEPT SELECT address FROM member WHERE Membership_card = 'Black'
Given the Table shop having columns as Shop_ID has datatype number, Address has datatype text, Num_of_staff has datatype text, Score has datatype number, Open_Year has datatype text which has Shop_ID and Given the Table member having columns as Member_ID has datatype number, Name has datatype text, Membership_card has datatype text, Age has datatype number, Time_of_purchase has datatype number, Level_of_membership has datatype number, Address has datatype text which has Member_ID and Given the Table happy hour having columns as HH_ID has datatype number, Shop_ID has datatype number, Month has datatype text, Num_of_shaff_in_charge has datatype number which has HH_ID and Given the Table happy hour member having columns as HH_ID has datatype number, Member_ID has datatype number, Total_amount has datatype number which has HH_ID. Answer the question by writing the appropriate SQL code. Which address do not have any member with the black membership card?
SELECT address FROM shop ORDER BY open_year
Given the Table shop having columns as Shop_ID has datatype number, Address has datatype text, Num_of_staff has datatype text, Score has datatype number, Open_Year has datatype text which has Shop_ID and Given the Table member having columns as Member_ID has datatype number, Name has datatype text, Membership_card has datatype text, Age has datatype number, Time_of_purchase has datatype number, Level_of_membership has datatype number, Address has datatype text which has Member_ID and Given the Table happy hour having columns as HH_ID has datatype number, Shop_ID has datatype number, Month has datatype text, Num_of_shaff_in_charge has datatype number which has HH_ID and Given the Table happy hour member having columns as HH_ID has datatype number, Member_ID has datatype number, Total_amount has datatype number which has HH_ID. Answer the question by writing the appropriate SQL code. Show the shop addresses ordered by their opening year.