Skip to content
Advertisement

How to get the sum of a column in SQL Server and display in a single query?

I have this table where I have three particular transactions: Billing, Penalty and Discount. I want to compute the billed amount ((Billing – Discount)+Penalty).

This should be the output

What I have tried so far: I managed to get the billed amount for each individual account:

Advertisement

Answer

I would use conditional aggregation here:

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement