Count Transactions by Customer
You've been asked to review the activity level of each customer by counting how many transactions they've made.
This kind of summary is useful when identifying frequent users or analyzing behavior across a large dataset.
To solve this, you'll use COUNT()
along with GROUP BY
to collapse the data into customer-level counts.
Task
From the transactions
table in the bank_transactions.sqlite
database, display:
customer_id
transaction_count
(use an alias forCOUNT(*)
)
Sort the results by transaction_count
in descending order to highlight the most active customers first.
How to solve it
Write a SQL query that counts how many transactions each customer has made.
Group the results by customer_id
, and use ORDER BY
to sort from most to fewest transactions.
Want to learn more?
Join CodeFriends Plus membership or enroll in a course to start your journey.