I need help adding to my SQL statement. All of the Data is located in the same table. My current code is as follows,
SELECT Date,
Val2,
SNumber,
SUM(isnull(L1,0) + isnull(L2,0) + isnull(L3,0)) As TotalR,
From Table1
Where Val2='Rep'
Group By
Value 2 has both "Store" and "Rep"
I have the total of L1,L2,and L3 coming in great (for Rep's). what i need help with is how to get the
total of "Store" L1,L2, and L3 where SNumber matches "Rep" and "Store"
Some of the "Reps" are in the same "store" and should have the same total.
Source Table
Date Val2 Snumber L1 L2 L3
x Store 1 11 5 4
x Store 2 6 8 10
x Rep1 1 5 2 1
x Rep2 1 6 3 3
x Rep3 2 2 1 5
x Rep4 2 3 3 3
x Rep5 2 1 4 2
Result
Date Val2 Snumber TotalR TotalS
x Rep1 1 8 20
x Rep2 1 12 20
x Rep3 2 8 24
x Rep4 2 9 24
x Rep5 2 7 24