【发布时间】:2011-12-04 01:31:45
【问题描述】:
我如何让它工作,它在没有 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
【问题讨论】:
-
希望此查询的目的是让您可以修复表结构并将其放入第一范式。
标签: tsql sql-server-2008