哪位高手:缺少右括号
SQL Server 2000里执行好好的,拿到Oracle9i里就不行,说缺少右括号(当然是把SUBSTRING改为substr的),什么意思啊,我google翻了半天,也没找出结论:
select xzjd_mc,sum(jfxzc_mj)as jfxzc_mj,
sum(cw325) as cw325
from
(
select XZJD_MC, B.jfxzc_mc,B.JFXZC_MJ,B.QX_DM,B.zq_dm,B.jfxzc_dm,
(select sum(tb_mj) from ST_DLTB where DL_DM= '325 ' and SZXZC_DM=JFXZC_MC group by JFXZC_MC)as cw325
from st_xzorjd as A
inner join st_jforxzc as B on SUBSTRING(A.XZJD_DM,7,3)=B.zq_dm
) as B
group by xzjd_mc
------解决方案----------------------去掉AS
select xzjd_mc,
sum(jfxzc_mj) as jfxzc_mj,
sum(cw325) as cw325
from
(select XZJD_MC,
B.jfxzc_mc,
B.JFXZC_MJ,
B.QX_DM,
B.zq_dm,
B.jfxzc_dm,
(select sum(tb_mj)
from ST_DLTB
where DL_DM= '325 '
and SZXZC_DM=JFXZC_MC
group by JFXZC_MC) cw325
from st_xzorjd A
inner join st_jforxzc B
on SUBSTRING(A.XZJD_DM,7,3)=B.zq_dm
) B
group by xzjd_mc;
------解决方案----------------------把设置的表别名 as 关键字去掉
select xzjd_mc,sum(jfxzc_mj)as jfxzc_mj,
sum(cw325) as cw325
from
(
select XZJD_MC, B.jfxzc_mc,B.JFXZC_MJ,B.QX_DM,B.zq_dm,B.jfxzc_dm,
(select sum(tb_mj) from ST_DLTB where DL_DM= '325 ' and SZXZC_DM=JFXZC_MC group by JFXZC_MC) as cw325
from st_xzorjd A
inner join st_jforxzc B on SUBSTR (A.XZJD_DM,7,3)=B.zq_dm
) B
group by xzjd_mc;