【发布时间】:2017-01-10 14:54:18
【问题描述】:
这是我的简单查询。
Declare @custName INT
Set @custName = 2
Select case @custName
when 1 then 'abc'
when 2 then 'xyz'
when 3 then 'pqr'
end
上述查询运行良好。
输出是
我正在考虑将列或标题名称指定为客户名称。
我尝试对查询进行一些排列。
Declare @custName INT Set @custName = 2 Select case @custName as CustomerName when 1 then 'abc' when 2 then 'xyz' when 3 then 'pqr' endDeclare @custName INT Set @custName = 2 Select CustomerName as case @custName when 1 then 'abc' when 2 then 'xyz' when 3 then 'pqr' end
但返回错误。
所以我的问题是如何分配一些适当的标题/列名?
【问题讨论】:
标签: sql sql-server sql-server-2012