In sql server I wrote the code below. My table name is Finding and when i finished the query I want to see final situation with "Select * from Findings" code
But its show me the first version of the table (with out calculated fields). Can you help me how can i fixed this , how can ı call the final table with one command
select *,
(
case
when C.ACTION_CO -B.CLOSE_ACT_CO > 0 then 'OPEN'
when C.ACTION_CO -B.CLOSE_ACT_CO <= 0 then 'CLOSED'
ELSE 'ERROR' end) as FINDING_ACTUAL_STATU
from (
select *,
([REPORT REF] +'-'+ [FINDING NO]) as ID_FINDING
from Findings) A
left join (
select
sum(case
when [RECO STATUS] = 'Closed' THEN 1
ELSE 0 end) as CLOSE_ACT_CO,
([REPORT REF] +'-'+ [FINDING NO]) as ID_FINDINGG
from Findings
--where [RECO STATUS] = 'Closed'
group by
([REPORT REF] +'-'+ [FINDING NO])
) B on (A.ID_FINDING = B.ID_FINDINGG)
left join (
select
([REPORT REF] +'-'+ [FINDING NO]) as ID_FINDING,
count(([REPORT REF] +'-'+ [RECO NO])) as ACTION_CO
from Findings
Group by
([REPORT REF] +'-'+ [FINDING NO])
) C on (A.ID_FINDING = C.ID_FINDING)