0

我有这样的 oracle 语法:

select 'Tanggal : '||to_char(c,'DD-MON-YYYY hh:mm:ss')||',' as Tgl,
case
    when (select ((a.sk/b.tot)*100)
          from (select count(to_char(response))sk
          from log where response like '%OK%')a,
         (select count(*)tot from log)b)<100
    then (select 'Error : '||to_char(response),count(to_char(response)) je
        from log
        group by to_char(response)
        order by je desc)
    else 
        (select 'Success Rate : '||substr((a.sukses/b.total)*100,1,5)||' %,'as Success_rate
            from (select count(to_char(response)) sukses from log where response like '%OK%')a, (select count(*) total from log)b)
    end as test
from log
where rownum <= 1;

但它发送错误消息ORA-00907: missing right parenthesis, ,它指的是“order by je desc”。
那么,我该怎么做才能没有错误?

4

1 回答 1

0

你的查询真的很丑,有很多事情要做来改进它,但是看看你代码中的奇怪的东西,有两个错误的语法

select ((a.sk/b.tot)*100)
from (select count(to_char(response))sk
from log where response like '%OK%')a,
(select count(*)tot from log)b)<100

您拥有的部分 )a, (select....不可能拥有这个。就像 (a,b)<100 没有意义

那么order by也是错误的。只需将其删除。然后再试一次

于 2015-07-22T08:02:01.533 回答