declare @table table (Customer char(1), Transaction char(3), Discount float);
insert into @table values
('A', '001', '10.1'),
('A', '001', '10.1'),
('A', '002', '20.2'),
('B', '003', '30.3'),
('B', '004', '40.4')
I am trying to do something like this:
SELECT Customer, (SELECT SUM(Discount) WHERE Transaction IS DISTINCT)
FROM @table
GROUP BY Customer
And the result should look like:
Customer Total Discount
--------------------------
A 30.3
B 70.7
So basically I need club all the discounts for every customer per transaction, because they are sometimes repeated in my data.