选择Case语句未给出以下查询的结果 [英] Select Case Statement is not given the result to the following query
本文介绍了选择Case语句未给出以下查询的结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
选择'经济'=(案例经济学为-1然后'缺席'其他经济学结束)
来自tblCOM的
。
查询运行时出现以下错误
转换失败将varchar值'Absent'转换为数据类型int。
select 'Economics'=(case Economics when -1 then 'Absent' Else Economics End)
from tblCOM.
the query is running with the following error
Conversion failed when converting the varchar value 'Absent' to data type int.
推荐答案
它不起作用,因为它没有以正确的模式写入。
你必须以这种方式写出正确的模式:
当经济学=' - 1'然后'缺席'时选择案例
其他经济学以经济学结束
来自tblCOM
或在你的情况下
select replace(经济学,' - 1','缺席')作为经济学
来自tblCOM
It doesn't work because it isn't written in the correct mode.
You have to write in the right mode as this way:
select case when economics ='-1' then 'Absent'
else Economics end as Economics
from tblCOM
or in you case
select replace(economics,'-1','Absent') as Economics
from tblCOM
这篇关于选择Case语句未给出以下查询的结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文