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

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -