我这里有个语句请看下为何报错
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
)
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 clbm ,
MAX(B.clmc) AS clmc ,
MAX(B.ggxh) AS ggxh ,
MAX(B.jldw) AS jldw ,
SUM(A.qmsdt) AS qmsdt ,
SUM(A.qmswkcl) AS qmswkcl ,
SUM(A.qmkcl) AS qmkcl ,
SUM(A.qmkce) AS qmkce ,
SUM(A.DptCnt) AS DptCnt ,
SUM(A.DptAmount) AS DptAmount
FROM ( 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)]
UNION ALL
SELECT clbm ,
0 ,
0 ,
0 ,
0 ,
sl ,
je
FROM [FixedAssset]
) AS A ,
[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 (s
elect clbm,dj,sum(qmswkcl) as qmswkcl from clpcb group by clbm,dj) as tmp where qmswkcl=0)] B
WHERE A.clbm = B.clbm
GROUP BY B.clbm
) AS TabTmp
WHERE 1 = 1
AND b.cllb = '家具'