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 customer id and number of accounts with most accounts.
assistant
SELECT customer_id , count(*) FROM Accounts GROUP BY customer_id ORDER BY count(*) DESC LIMIT 1
human
Show all customer ids and the number of accounts for each customer.
assistant
SELECT customer_id , count(*) FROM Accounts GROUP BY customer_id
human
How many customers have an account?
assistant
SELECT count(DISTINCT customer_id) FROM Accounts
human
Show the number of customer cards.
assistant
SELECT count(*) FROM Customers_cards
human
Show the number of all customers without an account.
assistant
SELECT count(*) FROM Customers WHERE customer_id NOT IN (SELECT customer_id FROM Accounts)
human
Count the number of customers.
assistant
SELECT COUNT( * ) FROM Customers ;