Question paper (build 07.05.20.19)
Question 6:
Picture 5.1
Write an SQL query to list all customers whose total spending on completed orders in 2025
is below the average total spending in 2025 of all customers, including those who made no
orders. For each customer, display: CustomerID, FullName, TotalAmount (the total value of
all completed orders in 2025 (use 0 for customers with no orders)). Ensure calculating the
average total spending based on all customers, including those with 0 spending. Sort the
output by TotalAmount in descending order, then by CustomerID in ascending order for
customers having the same TotalAmount.
5 of 5
Paper No: 10
CustomerID
FullName
TotalAmount
12
2
45
46
Phạm Văn Quang
1315000.00
45
Lê Thị Tâm
1310000.00