Hi,
I have a SQL select query, it works fine as it is now.
But I would like to be able to get the result of each case ex: final result of "FIRST RESULT" and "SECOND RESULT" and to be able to reuse it in my next line of code likeCode:select namee as 'FULL NAME', sum(inn) as 'Money', sum(case when color='red' or color='MEDIUM red' or color = 'LIGHT red' then isnull(out,0) else 0 End) as 'FIRST RESULT', sum(case when color='red' or color='MEDIUM LIGHT red' then isnull(inn,0) - isnull(out,0) else 0 End) as 'SECOND RESULT' from yyyyyyyy where ID = 100 group by namee
I'm not sure how i can accomplish that, any tip will be appreciated.Code:sum(case when color='red' or color='MEDIUM LIGHT red' then isnull(inn,0) - isnull('FIRST RESULT',0) else 0 End) as 'THIRD RESULT'
Thanks


Reply With Quote