human
Schema:
Accounts (account_id, customer_id, account_name, other_account_details)
Customers (customer_id, customer_first_name, customer_last_name, customer_address, customer_phone, customer_email, other_customer_details)
Customers_Cards (card_id, customer_id, card_type_code, card_number, date_valid_from, date_valid_to, other_card_details)
Financial_Transactions (transaction_id, previous_transaction_id, account_id, card_id, transaction_type, transaction_date, transaction_amount, transaction_comment, other_transaction_details)
Please answer with SQL.
assistant
Sure, I understand.
human
Show the card type codes and the number of transactions.
assistant
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
human
What is the average and total transaction amount?
assistant
SELECT avg(transaction_amount) , sum(transaction_amount) FROM Financial_transactions
human
Show all transaction types.
assistant
SELECT DISTINCT transaction_type FROM Financial_Transactions
human
Show the transaction type and the number of transactions.
assistant
SELECT transaction_type , count(*) FROM Financial_transactions GROUP BY transaction_type
human
What is the transaction type that has processed the greatest total amount in transactions?
assistant
SELECT transaction_type FROM Financial_transactions GROUP BY transaction_type ORDER BY sum(transaction_amount) DESC LIMIT 1
human
How many different types of transactions are there?
assistant
SELECT COUNT( DISTINCT transaction_type ) FROM Financial_Transactions ;