繁体   English   中英

MYSQL使用xase语句创建表作为选择,将字段转换为编号值

[英]MYSQL Creating table as select with xase statement converting field to numbered value

我有以下 MYSQL 查询,该查询将表创建为 select 语句,但有一个 case 语句将字段格式更改为编号字段以进行比较:

CREATE TABLE wm.bochg
AS
SELECT 
wca.bochg.BochgID,
wca.bochg.SecID,
wca.bochg.OldOutValue,
wca.bochg.NewOutValue,
case when NewOutValue+0.0 >= OldOutValue+0.0 then NewOutValue ELSE '' END AS test2
from wca.bochg
WHERE
wca.bochg.SecID in (select secid from client.pfisin where accid = 416)

AND (wca.bochg.BochgID is null or wca.bochg.BochgID =
(select subbochg.BochgID from wca.bochg as subbochg
where subbochg.secid=bochg.secid
AND subbochg.Actflag <> 'D'
AND subbochg.NewOutValue+0.0 >= subbochg.OldOutValue+0.0
order by subbochg.BochgID desc limit 1)
or wca.bochg.BochgID is NULL);

但是,当它被创建时我收到警告说:'截断不正确的 DOUBLE 值:'''

这是由于我的案例陈述和我的子查询中的 and 子句。 有没有办法解决这个问题并摆脱上面的警告信息? 谢谢

您在 case 语句中混合数据类型。 对 ELSE 部分使用字符串 '' 以外的其他内容(NULL、0 或任何适合您目的的内容)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM