在視圖中,我將一個select語句放在一個案例中,並將其作爲列進行了擴展。列名是'IR2'使用Microsoft SQL在創建的列上創建案例表達式
我該如何關閉「IR2」列?
我最終得到一個錯誤,說'無效列名'IR2'。
我的選擇是什麼?
case when r.ana = 'nh3' and r.serv='energy' and exists(select 1 from results x where x.no=r.no and x.ana='nh3' and x.sa='rejected' and x.serv <> 'energy')
then '*' else r.sa end as IR2,
CASE IR2 WHEN 'Released' then
''
ELSE
'*'
END AS IR
您不能在select子句中使用別名IR2 – sle1306