+ -
当前位置:首页 → 问答吧 → oracle 语句中 case when缺少右括号

oracle 语句中 case when缺少右括号

时间:2011-12-03

来源:互联网

select substr(to_char(t.grosstime,'yyyy-mm-dd'),9,10) as dates ,
sum(decode(varno, '0102010105000000', netweight,0)) "JMton",
sum(case when t.borrowflag='0'and t.varno='0102010105000000'then 1 else 0 end) as "JMnum",
from table_1 t
where to_char(t.grosstime, 'yyyy-mm') = '2010-10' and t.minecode="150000" and t.transway='1' and t.flag='1' 
group by substr(to_char(t.grosstime,'yyyy-mm-dd'),9,10)
order by substr(to_char(t.grosstime,'yyyy-mm-dd'),9,10)

用plsql执行没问题,在报表中就报缺少右括号。。。主要就是第三行case when,该怎么办呢?

作者: zhu757007369   发布时间: 2011-12-03

case when似乎没有问题,
第3行末尾多个逗号
第2行似乎写得也不够工整。

作者: magong   发布时间: 2011-12-03

PL-SQL没问题才见鬼。

作者: forgetsam   发布时间: 2011-12-03

SQL code
select substr(to_char(t.grosstime, 'yyyy-mm-dd'), 9, 10) as dates,
       sum(decode(varno, '0102010105000000', netweight, 0)) as JMton,
       sum(case
             when t.borrowflag = '0' and t.varno = '0102010105000000' then
              1
             else
              0
           end) as "JMnum",
  from table_1 t
 where to_char(t.grosstime, 'yyyy-mm') = '2010-10'
   and t.minecode = "150000"
   and t.transway = '1'
   and t.flag = '1'
 group by substr(to_char(t.grosstime, 'yyyy-mm-dd'), 9, 10)
 order by substr(to_char(t.grosstime, 'yyyy-mm-dd'), 9, 10)

作者: hllfl   发布时间: 2011-12-03

mm--->MM

作者: hllfl   发布时间: 2011-12-03

热门下载

更多