-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRetailReports
More file actions
58 lines (48 loc) · 1.35 KB
/
Copy pathRetailReports
File metadata and controls
58 lines (48 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
USE storemanager
GO
--update store city in tblstores based on StoreID
UPDATE tblStore
SET StoreCity = 'Kansas City'
WHERE StoreID = '10200'
SELECT SaleAmount
FROM tblEmployeeEarnings
GROUP BY SaleAmount
SELECT SaleAmount
FROM tblEmployeeEarnings
GROUP BY SaleAmount
SELECT EmployeeLossAmount
FROM tblEmployeeLoss
GROUP BY EmployeeLossAmount
SELECT EmployeeLossAmount
FROM tblEmployeeLoss
GROUP BY EmployeeLossAmount
SELECT Month,
ProductID,
sum(SaleAmount) as Total_Revenue
FROM tblEmployeeEarnings
GROUP BY ProductID, Month
SELECT Month,
CustomerID,
sum(SaleAmount) as Total_Revenue
FROM tblEmployeeEarnings
GROUP BY CustomerID, Month
SELECT sum(Inventory)
FROM tblProduct
GROUP BY Inventory, DepartmentID
--To delete a parent record in which there is one or more related child records, the child records
--must be deleted first before the parent
--delete department associated with store that needs to be deleted from tblstores based on StoreID
BEGIN TRAN
DELETE FROM tblOrderLineItem
where ProductID = '200006'
COMMIT TRAN;
--delete store from tblstores based on StoreID (USING A TRANSACTION WITH ERROR HANDLER)
--LEFT IN THE FOLLOWING TO SHOW HOW ERROR MESSAGES WORK IN SQL (STUDENT NOTE)
BEGIN TRAN
DELETE FROM tblPick_Up_Order
where StoreID = '10200'
IF (@@ERROR <> 0) BEGIN
PRINT 'Unexpected error occurred!'
ROLLBACK TRAN
END
COMMIT TRAN