Skip to content
Advertisement

SQL Server Sum specific transaction type amounts

I have a temp table (#general) that contains Account number, transaction type, Amount info as below

I am trying to calculate the percentage of sum of a specific transaction type in total amount by account number.. as in below:

However, i got same percentage for all account numbers, which is percentage of all, i presume.

What do i do wrong?

Advertisement

Answer

Try the below using conditional aggregation

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