I\'m in a weird situation with my query. My objective is to display the total deposits and withdrawals from multiple transactions for each person and display them. I am getting
Try this:
SELECT lastname,firsname,
SUM(case when upper(category) = 'W' then abs(principal) end) as Withdrawal,
SUM(case when upper(category) = 'D' then abs(principal) end) as Deposit,
description
FROM
table1
JOIN table2 ON table1.id = table2.id
JOIN table3 ON table2.c = table3.c
WHERE
description = 'string'
GROUP BY
lastname,firstname,description