wtsumpes
asked on
How do I sum only negative field values in MS SQL reports
Hi Xperts.
This might be an easy answer for you guys, but its a tough question for me!
I've built a simple SQL report which needs to total wirless accounts which have negative message balances on their unit's.
and then sum only the negative values in order to produce a total of the negative numbers ignoring the positive numbers.
EXAMPLE of what I need:
Record 1 Value 2
Record 2 Value -2
Record 3 Value -2
SUM of ALL records = -4 which ignores the positive numbers
My current formula doesn't work because it 'sums' everything instead of just negative numbers.
=Sum(Fields!OverageRemain. Value)
Thank you very much for your help.
Bill
This might be an easy answer for you guys, but its a tough question for me!
I've built a simple SQL report which needs to total wirless accounts which have negative message balances on their unit's.
and then sum only the negative values in order to produce a total of the negative numbers ignoring the positive numbers.
EXAMPLE of what I need:
Record 1 Value 2
Record 2 Value -2
Record 3 Value -2
SUM of ALL records = -4 which ignores the positive numbers
My current formula doesn't work because it 'sums' everything instead of just negative numbers.
=Sum(Fields!OverageRemain.
Thank you very much for your help.
Bill
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Have you tried my solution? It should work for you.
Select Account, SUM(OverageRemain)
From TableName
Where SIGN(OverageRemain) != 1
Group By Account