Q1_20251108073208.webp
M

Q1_20251108073208.webp

8 of 8
Paper No: 7
2345
Month
1
1/2023 1
2/2023 0
NumberOfOrders Total Revenue
475000.00
0.00
3/2023 4
3315000.00
4/2023 2
1390000.00
5/2023 1
575000.00
6
6/2023 4
2115000.00
7
7/2023 1
1105000.00
8
8/2023 1
1070000.00
9
9/2023 1
347000.00
10
10/2023 2
11
11/2023 1
12
12/2023 0
2111000.00
525000.00
0.00
Picture 8.1
Question 9:
Create a trigger named trg_Update TotalAmount on the OrderDetails table to ensure the
TotalAmount column in the Orders table always stays accurate.
Whenever an OrderDetails record is inserted, updated, or deleted, the trigger should
automatically recalculate the total amount of the affected orders as the sum of (Quantity *
Price) for all its items. If all OrderDetails of an order are deleted, the total amount of this
order should be set to 0.
For example, if you run the following queries on the table OrderDetails, the corresponding
orders will be updated.
-- test case 1 -> TotalAmount of the orders with OrderID = 3 and OrderID = 5 will be updated
INSERT OrderDetails (OrderID, ItemID, Quantity, Price)
VALUES (3, 2, 3, 75000.00), (5,27,2,40000.00)
Zoom
+10 %
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
615
Lượt bình luận
0
Rating
0.00 star(s) 0 đánh giá

Share this media

Back
Bên trên Bottom