Lecture
Count Transactions by Customer
You’ve been asked to analyze customer activity levels by counting how many transactions each customer has made.
This type of summary helps identify frequent users and reveal behavioral patterns in large datasets.
You’ll use COUNT() together with GROUP BY to calculate transaction totals per customer.
Task
From the transactions table in the bank_transactions.sqlite database, display:
customer_idtransaction_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.
Previous lessonUse Logical AND/OR to Filter Hotel DataNext lessonCalculate Average Spending per Client
Lessons in this chapter · Solve real-world problems with SQL.
- 1. Filter Bookings by Region
- 2. Sort and Limit Recent Reservations
- 3. Use Logical AND/OR to Filter Hotel Data
- 4. Count Transactions by Customer
- 5. Calculate Average Spending per Client
- 6. Filter Customers with High Transaction Totals
- 7. Join Flights with Passengers
- 8. List Passengers with No Reservations
- 9. Find Customers with High-Priced Ticket Purchases
- 10. Filter Events with Above-Average Ticket Sales
sqlQuiz
?
Lecture
AI Tutor
Design
Upload
Notes
Favorites
Help