Skip to content
Advertisement

SQL oracle: How can I get the results of 4 selects statements added & subtracted to get one value with a ‘WITH’ keyword

My code is:

The result of each select statement in the with clause returns one value. I am trying to add the expenses and subtract it from the income. When I run the whole code I am getting some error which I am unable to figure out. Am I doing something wrong? I want the result from the aliases in this format [D_INC – (A_EXP + B_EXP + C_EXP)] and I want the result to be one value, i.e.,

EXPECTED OUTPUT:

Advertisement

Answer

Please use below query , in last statement of your query I have just used column name instead of cte name .

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement