我这里有个语句请看下为何报错
Select clbm,qmsdt,qmswkcl,qmkcl,qmkce,0 As DptCnt,0 As DptAmount From
[clpcb as a ,cldmb as b where 1=1 and a.clbm=b.clbm And convert(char(20),a.clbm)+'_'+convert(char(20),a.dj) not in(select convert(char(20),clbm)+'_'+convert(char(20),dj) from (select clbm,dj,sum(qmswkcl) as qmswkcl from clpcb group by clbm,dj) as tmp where qmswkcl=0
)]
提示:以 'clpcb as a ,cldmb as b where 1=1 and a.clbm=b.clbm And convert(char(20),a.clbm)+'_'+convert(char(20),a.dj) not in(select conve' 开头的 标识符 太长。最大长度为 128。
------解决方案--------------------你加中括号干什么用的?
Select clbm,qmsdt,qmswkcl,qmkcl,qmkce,0 As DptCnt,0 As DptAmount
From clpcb as a ,cldmb as b
where 1=1 and a.clbm=b.clbm And convert(char(20),a.clbm)+'_'+convert(char(20),a.dj)
not in (select convert(char(20),clbm)+'_'+convert(char(20),dj)
from (select clbm,dj,sum(qmswkcl) as qmswkcl from clpcb group by clbm,dj) as tmp
where qmswkcl=0
)
------解决方案--------------------帮你整理格式,点编译的确报你的错,问题就是from 那里不能用[],你改成小括号试试,不过不可能突然就不行的,一定是有人有意无意改过
SELECT cllb ,
clbm ,
clmc ,
ggxh ,
jldw ,
qmsdt ,
qmswkcl ,
qmkcl ,
qmkce ,
DptCnt ,
DptAmount ,
( CASE qmkcl
WHEN 0 THEN 0
ELSE ROUND(qmkce / qmkcl, 2)
END ) AS dj
FROM ( SELECT MAX(B.cllb) AS cllb ,
B.clbm AS clb