Lecture
Calculate Average Spending per Client
The analytics team wants to understand how much each customer spends on average per transaction.
You’ve been asked to prepare a quick report to help identify high-value clients.
You’ll use the AVG() function with GROUP BY to calculate the average transaction amount per customer.
Task
From the transactions table in the bank_transactions.sqlite database, display:
customer_idaverage_spending(use an alias for the average)
Round the result to 2 decimal places, and sort by average_spending in descending order to see the top spenders first.
How to solve it
Write a SQL query that calculates the average amount spent per transaction for each customer.
Use GROUP BY to group data by customer_id, and use ROUND(AVG(...), 2) to format the average.
Previous lessonCount Transactions by CustomerNext lessonFilter Customers with High Transaction Totals
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