sql - Subtract grouped figures in Oracle select Statement -
i have interest table interest indicator either credit or debit. requirement difference between credit , debit interest grouping branch. separated queries are:
select sol_id, sum(amount_in_lcy)debit_interest interest_details int_id = 'd' group sol_id;
my other query is:
select sol_id, sum(amount_in_lcy)credit_interest interest_details int_id = 'c' group sol_id;
i totally stuck on adding or subtracting 2 queries 1 resultset grouped sol_id. ideas?? there way subtract figures first , group them?
select sol_id, (sum(case when int_id = 'c' amount_in_lcy else 0 end)- sum(case when int_id = 'd' amount_in_lcy else 0 end)) difference interest_details group sol_id;
Comments
Post a Comment