我如何得到这个工作,它没有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
希望这个查询的目的是使您可以修复你的表结构,并把它变成第一范式。 –