Q1_20251108073155.webp
M

Q1_20251108073155.webp

Picture 4.1
Question 5:
Write an SQL query to list all customers whose full name starts with "Nguyễn" or "Bui",
showing for each customer: CustomerID, FullName, the number of completed orders they
made in the year 2025 (column NumberOfOrders), and the total amount spent on those
orders (column TotalAmount). If a customer has no completed order in 2025, still display
their name with NumberOfOrders = 0 and TotalAmount = 0.
CustomerID FullName
NumberOfOrders
TotalAmount
1
2
1
7
Nguyễn Thị Mai
2
1902000.00
Bùi Thị Ngọc
0
0.00
3
4
7
8
#569% 912345
10
11
85282332748
Nguyễn Hoàng Nam
1
573000.00
14
Bùi Văn Lâm
0
0.00
15
Nguyễn Thị Hồng
3
1576000.00
21
Bùi Thị Nhung
3
2156000.00
Nguyễn Văn Tín
1
900000.00
Bùi Ngọc Linh
1
570000.00
29
Nguyễn Văn Khánh
1
405000.00
Bùi Thị Trang
2
1155000.00
36
Nguyễn Hoài Phương
0.00
Bùi Thanh Bình
6
1947000.00
Nguyễn Lan Hương
0
0.00
49
Bùi Thị Thu Hà
3
50
Nguyễn Quốc Đạt
1
1215000.00
800000.00
Picture 5.1
Question 6:
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
5 of 5
Paper No: 7
Zoom
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.
+ 100%
Close
Chưa có bình luận nào.

Thông tin

Category
DBI202
Thêm bởi
morning_sun
Ngày thêm
Lượt xem
1,282
Lượt bình luận
0
Rating
0.00 star(s) 0 đánh giá

Share this media

Back
Bên trên Bottom