select xq,sum(zse) from(select sum (distinct b.se) as zse, 
(case when d.swjg_mc like '%1%'  then '1' 
                    when d.swjg_mc like '%2%'  then '2' 
                    when d.swjg_mc like '%3%'  then '3' 
                      when d.swjg_mc like '%4'  then '4' 
                      when d.swjg_mc like '%5%'  then '5' 
                        when d.swjg_mc like '%6%'  then '6' 
                      else '出错' end ) as xq from sb_zzs_2003_ybnsr a, sb_zzs_2003_fb2 b,dj_nsrxx c,dm_swjg d 
        where a.pzxh=b.pzxh and to_char(a.sssq_q,'yyyy-mm')='2008-02' and b.yxbz='Y' and b.fblc='1' and a.nsr_swjg_dm=d.swjg_dm group by d.swjg_mc) group by xq 在plsql中可以正常运行,在JSP中却报错。  在JSP中报错ora00905 缺少关键字 ,请各位大虾帮助看下。

解决方案 »

  1.   

    说明你jsp中拼接sql不对。把jsp最终执行前的sql打印出来,看看是否有语法错。
      

  2.   

    把“case … when ……”改成“Decode”语句看看。
      

  3.   

    测试了哈,取掉(case when d.swjg_mc like '%1%'  then '1' 
                        when d.swjg_mc like '%2%'  then '2' 
                        when d.swjg_mc like '%3%'  then '3' 
                          when d.swjg_mc like '%4'  then '4' 
                          when d.swjg_mc like '%5%'  then '5' 
                            when d.swjg_mc like '%6%'  then '6' 
                          else '出错' end ) 
    替换成 d.swhg_mc 可以正常运行。怀疑是不是 <%@page import=java.sql.*%> 不支持case