infobright开发-数字类型与字符类型union后,op_day_id有一行变成NULL值,如下例子:
select distinct a.app_id, a.imei, a.op_day_id, b.first_boot_time
from A ajoin B b
on a.day_id =${ETLDate}
and a.imei = b.imei
and a.app_id = b.app_id
union all
SELECT b.app_id,
b.imei,
date_format(b.first_boot_time, '%Y%m%d'),
b.first_boot_time
FROM B b
WHERE date_format(b.first_boot_time, '%Y%m%d')=${ETLDate};
不会像oracle那样字段类型字段转化,也不报错,真是坑!不知mysql下面是否一样,待测试!
解决:
采用cast进行类型转化 cast (col as SIGNED) ,cast 用法:
二进制,同带binary前缀的效果 : BINARY
字符型,可带参数 : CHAR()
日期 : DATE
时间: TIME
日期时间型 : DATETIME
浮点数 : DECIMAL
整数 : SIGNED
无符号整数 : UNSIGNED