I got stuck in a scenario where I need to add columns from two rows after using GROUP BY.
My query goes as:
select AcctId,DC,sum(TrnAmt) from TableId
group by AcctId,DC
order by AcctId,DC
Result:-
VcrAcctId DrCr SumTranAmt
51 C 37469
51 D 37000
My expected result is:
VcrAcctId Actual
51 37469-37000
How can I get my expected result in the same query?
Based on discussion in the comments I think you need
If in fact you do want the credits and debits split out you can use
You could cast the
SUMexpressions tovarcharand concatenate them to get the results shown in the question if that is what is actually needed.