我正在尝试向SQLServer2008Express表中添加计算列。
公式是:
case when callrecord_contacttype=1 then 'Routed voice'
else when callrecord_contacttype=2 then 'Direct incoming voice'
else when callrecord_contacttype=3 then 'Direct outgoing voice'
else when callrecord_contacttype=4 then 'Direct internal voice'
else when callrecord_contacttype=5 then 'Routed callback'
else when callrecord_contacttype=6 then 'Routed email'
else when callrecord_contacttype=7 then 'Direct outgoing email'
else when callrecord_contacttype=8 then 'Routed chat' else '' end但我发现了错误:
在关键字'when‘附近有错误的语法。
发布于 2014-01-08 09:41:27
试着:
case callrecord_contacttype
when 1 then 'Routed voice'
when 2 then 'Direct incoming voice'
when 3 then 'Direct outgoing voice'
when 4 then 'Direct internal voice'
when 5 then 'Routed callback'
when 6 then 'Routed email'
when 7 then 'Direct outgoing email'
when 8 then 'Routed chat'
else ''
end有关语法,请参见http://msdn.microsoft.com/en-us/library/ms181765.aspx。
发布于 2014-01-08 09:41:53
查询中只有一个ELSE:
case when callrecord_contacttype=1 then 'Routed voice'
when callrecord_contacttype=2 then 'Direct incoming voice'
when callrecord_contacttype=3 then 'Direct outgoing voice'
when callrecord_contacttype=4 then 'Direct internal voice'
when callrecord_contacttype=5 then 'Routed callback'
when callrecord_contacttype=6 then 'Routed email'
when callrecord_contacttype=7 then 'Direct outgoing email'
when callrecord_contacttype=8 then 'Routed chat'
else '' end发布于 2014-01-08 09:42:05
else只属于最后的非条件子句:
case when callrecord_contacttype=1 then 'Routed voice'
when callrecord_contacttype=2 then 'Direct incoming voice'
when callrecord_contacttype=3 then 'Direct outgoing voice'
when callrecord_contacttype=4 then 'Direct internal voice'
when callrecord_contacttype=5 then 'Routed callback'
when callrecord_contacttype=6 then 'Routed email'
when callrecord_contacttype=7 then 'Direct outgoing email'
when callrecord_contacttype=8 then 'Routed chat'
else '' endhttps://stackoverflow.com/questions/20991842
复制相似问题