SQL“截断的INTEGER值不正确”错误

时间:2013-09-18 10:27:42

标签: mysql sql syntax-error

create table ApplicationTracker_dup1
select transactionid,
       count(case when attribute = 'Secci_Page_Arrival_Time' and value is not null then transactionid end)as secci_visits,
       count(case when attribute = 'esign_arrival_time' and value is not null then transactionid end)as esig_visits 
from ApplicationTracker_dup 
where create_dtm < '2013-08-13' 
group by 1;

当我运行此代码时,遇到

  

ERROR 1292(22007):截断错误的INTEGER值:'E031CF1DE8F7'“

并且没有创建表。有人可以帮助我吗?

2 个答案:

答案 0 :(得分:1)

很遗憾,您没有发布ApplicationTracker_dup表定义脚本,因此我建议尝试使用select子句中的attribute列或使用create_dtm列进行强制转换:

cast(attribute as char)

cast(create_dtm as char)

答案 1 :(得分:1)

你应该在 count func中使用int或NULL,而不是char和其他类型 所以,这段代码应该没有警告:

create table ApplicationTracker_dup1
select transactionid,
       count(if(attribute = 'Secci_Page_Arrival_Time' and value is not null,1,NULL)) as secci_visits,
       count(if(attribute = 'esign_arrival_time' and value is not null,1,NULL)) as esig_visits 
from ApplicationTracker_dup 
where create_dtm < '2013-08-13' 
group by 1;
相关问题