我如何得到這個工作,它沒有Where子句,否則與Where子句,我得到明顯的錯誤,但基本上需要做什麼,任何人都知道如何處理這個?在哪裏條款或替代選項中使用別名?
select ID,
Name,
case T.N
when 1 then City1
when 2 then City2
when 3 then City3
end as City,
case T.N
when 1 then State1
when 2 then State2
when 3 then State3
end as State
from YourTable
cross join (values(1),(2),(3)) as T(N)
Where City is NOT Null
希望這個查詢的目的是使您可以修復你的表結構,並把它變成第一範式。 –