case
我在下面标记的行中有问题。
我需要它显示为
debits | credits | total debits | total credits
SQL查询是:
SELECT cv_amount,
case when cv_amount > 0 then cv_amount else 0 end as debits,
case when cv_amount < 0 then cv_amount*-1 else 0 end as credits,
sum(case when cv_amount > 0 then cv_amount else 0)--- ERROR SHOWEN HERE--- end as d,
sum(case when cv_amount < 0 then cv_amount*-1 else 0) end as c
FROM dof
where currency_code = 368
AND to_DATE('05/05/19', 'DD/MM/YY') and to_DATE('05/05/19', 'DD/MM/YY')
group by cv_amount