select id, name ,case when edutype is null then degreetype
when degreetype is null then edutype
else degreetype || edutype end as v from evw_BIZ_REGISTER c where c.studytype=2;
执行这句的时候就是数据类型不一样,应为number,但却获得char,应该怎么改,degreetype,edutype,studytype都是integer类型,求支招🙏🏻
degreetype和edutype 是数字,但是 degreetype || edutype 是字符串 ,所以有两种修改方式
1.全部定义成字符串
select id, name ,case when edutype is null then to_char(degreetype)
when degreetype is null then to_char(edutype)
else degreetype || edutype end as v from evw_BIZ_REGISTER c where c.studytype=2;
2.全部定义成数字
select id, name ,case when edutype is null then degreetype
when degreetype is null then edutype
else to_number(degreetype || edutype) end as v from evw_BIZ_REGISTER c where c.studytype=2;
那你v这一列到底想要什么数据类型啊,怎么一会放个int进去,一会又拼接字符串
如果要拼接,那你统一都转成char
如果想让它是int类型,那你应该把拼接好的字符串转回int
总之应该让类型统一,不要不同分支下类型都不一样