Issue Calculating from Rows and Columns(Summing two columns with the third of a different row)
- by vstsdev
With reference to my previous question
Adding columns resulting from GROUP BY clause
SELECT AcctId,Date,
Sum(CASE
WHEN DC = 'C' THEN TrnAmt
ELSE 0
END) AS C,
Sum(CASE
WHEN DC = 'D' THEN TrnAmt
ELSE 0
END) AS D
FROM Table1 where AcctId = '51'
GROUP BY AcctId,Date
ORDER BY AcctId,Date
I…