幫我看下下面的代碼是什麼錯的幫我修改下
select * from ( select CALN.NA_NO,CALN.CAL_TYPE,CALN.NAERR_NO,TCMSMAIN.DUE_DATE,CALN.E_DATE, CALN.CAL_DATE CALN_CALDATE,
deptname=
case
when CALN. DEPTNO in ( 'CC3-','CE6-','CC2-','CM2-','CM7-','CM8-','CE5-','CM1-','CM3-','CM9-') then '馬達,CC3,CE6,CC2,
CM2,CM7,CM8,CE5,CM1,CM3,CM9'
WHEN CALN.DEPTNO IN('CP4-') THEN 'AV揚聲器 , CP4'
WHEN CALN.DEPTNO IN('CS1-') THEN 'CAR揚聲器 , CS1'
WHEN CALN.DEPTNO IN('CU1-') THEN '電容器 , CU1'
WHEN CALN.DEPTNO IN('CD1-') THEN '監視器 , CD1'
WHEN CALN.DEPTNO IN('CM5-') THEN '制面包機 , CM5'
WHEN CALN.DEPTNO IN('CM6-') THEN '果汁機 , CM6'
WHEN CALN.DEPTNO IN('CT1-') THEN '電烤箱 , CT1'
WHEN CALN.DEPTNO IN('CJ1-') THEN '電磁爐 , CJ1'
WHEN CALN.DEPTNO IN('CCO-') THEN '汽車空調 , CCO'
WHEN CALN.DEPTNO IN('CL1-') THEN '空調器 , CL1'
WHEN CALN.DEPTNO IN('CK1-') THEN '汽車電子 , CK1'
ELSE CALN.DEPTNO
END
from TCMSCALN LEFT JOIN( select NA_NO,CAL_DATE, CAL_TYPE, NAERR_NO from TCMSCALN
join ( select DISTINCT DUE_DATE from TCMSMAIN) ) CALN ON TCMSMAIN
where substring(TCMSMAIN.DUE_DATE ,1,6) < '200710' or substring(CALN.E_DATE ,1,6) = '200710' or substring(CALN.CAL_DATE ,1,6) = '200710'