【DM版本】: DM Database Server 64 V8
【操作系统】:Kylin v10
【问题描述】*:某服务器上执行 sql 总是报最后一行语法错误(-2007), 无具体行列错误. 其他服务器上数据库(6-2 版本)不报错, 可正常执行. 均无屏蔽关键字. 单独执行 with kul2 中的语句正常. 是否是 sum() 跟 case when 以及 group by 同时使用在此版本(6-1 版本)数据库上不支持?
id_code: 出错 6-1-xx-ENT 版本; 正常 6-2-xx-ENT 版本
错误信息如下:
第 38 行附近出现错误[-2007]: 语法分析出错.
当删掉 38 行后, 则报 37 行错误
sql 如下:
with kul2 as (
select kul.id, kul.orgid, kul.frorgid, kul.loanstatus, kul.currentstatus, kul.kdway, kul.zrcode, kul.clyhcode, kul.refuse_way, if(timestampdiff(SECOND, kulp.begintime, kulp.endtime) > 3600, 1, 0) isovertime
from (select id, orgid, frorgid, loanstatus, currentstatus, kdway, zrcode, clyhcode, refuse_way from "XEDWX"."WDK_KD_USER_LOAN" where createtime between '2023-01-01 00:00:00' and '2023-06-30 23:59:59') kul
left join (select loanid, begintime, ifnull(endtime, now()) as endtime from (select loanid, begintime, endtime, row_number() over (partition by loanid order by createtime desc) as row_number from "XEDWX"."WDK_KD_USER_LOAN_PROCESS") kulp where row_number = 1) kulp on kulp.loanid = kul.id
)
select ca1.areaname, cd1.d_name, kul3.* from (
select
frorgid,
sum(1) as "kdway_total",
sum(case kdway when '4' then 1 else 0 end) as "phone_bank_num",
sum(case kdway when '0' then 1 else 0 end) as "wechat_num",
sum(case kdway when '1' then 1 else 0 end) as "wmp_num",
sum(case kdway when '2' then 1 else 0 end) as "phone_num",
sum(case kdway when '3' then 1 else 0 end) as "96668_num",
sum(case when kdway not in ('0', '1', '2', '3', '4') then 1 else 0 end) as "other_num",
sum(1) as "process_total",
sum(case when loanstatus = '0' and currentstatus = '0' and zrcode = '1' then 1 else 0 end) as "kf_undo_num",
sum(case when loanstatus = '0' and currentstatus = '0' and zrcode = '1' and isovertime = 1 then 1 else 0 end) as "kf_undo_overtime_num",
sum(case when loanstatus = '1' and currentstatus in ('1', '2', '3', '4') and zrcode = '1' then 1 else 0 end) as "kf_done_num",
sum(case when loanstatus = '1' and currentstatus in ('1', '2', '3', '4') and zrcode = '1' and isovertime = 1 then 1 else 0 end) as "kf_done_overtime_num",
sum(case when loanstatus = '1' and (currentstatus is null or currentstatus = '') and zrcode = '1' then 1 else 0 end) as "auto_done_num",
sum(case when loanstatus = '1' and (currentstatus is null or currentstatus = '') and zrcode = '1' and isovertime = 1 then 1 else 0 end) as "auto_done_overtime_num",
sum(case when loanstatus = '2' and zrcode = '1' then 1 else 0 end) as "accept_num",
sum(case when loanstatus = '2' and zrcode = '1' and isovertime = 1 then 1 else 0 end) as "accept_overtime_num",
sum(case when refuse_way = '1' and zrcode = '0' then 1 else 0 end) as "bank_intercept_num",
sum(case when refuse_way = '1' and zrcode = '0' and isovertime = 1 then 1 else 0 end) as "bank_intercept_overtime_num",
sum(case when refuse_way = '2' and zrcode = '0' then 1 else 0 end) as "third_intercept_num",
sum(case when refuse_way = '2' and zrcode = '0' and isovertime = 1 then 1 else 0 end) as "third_intercept_overtime_num",
sum(case when loanstatus = '-1' and currentstatus = '-1' and zrcode = '1' then 1 else 0 end) as "kf_reject_num",
sum(case when loanstatus = '-1' and currentstatus = '-1' and isovertime = 1 then 1 else 0 end) as "kf_reject_overtime_num",
sum(case when loanstatus in ('-2', '-3') and zrcode = '1' then 1 else 0 end) as "khjl_reject_num",
sum(case when loanstatus in ('-2', '-3') and zrcode = '1' and isovertime = 1 then 1 else 0 end) as "khjl_reject_overtime_num",
sum(case when loanstatus = '3' and zrcode = '1' then 1 else 0 end) as "khjl_done_num",
sum(case when loanstatus = '3' and zrcode = '1' and isovertime = 1 then 1 else 0 end) as "khjl_done_overtime_num"
from kul2 group by frorgid
) kul3
left join "XEDWX"."CONN_DEPARTMENT" cd1 on cd1.d_id = kul3.frorgid
left join "XEDWX"."CONN_AREA" ca1 on ca1.id = kul3.frorgid;
除了数据库版本外,dm.ini参数一致么