Oracle -嵌套查询用例



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,它指的是"按顺序排序"。
那么,我该怎么做才不会出现错误呢?

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

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也是错误的。把它拿掉。再试一次

相关内容

  • 没有找到相关文章

最新更新