I am trying to use a subquery within a Case statement with a 'where' condition that binds to the parent query. Like this:
select 'Tanggal : '||to_char(trxdate,'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;
But, it issued an error ORA-00907: missing right parenthesis, I try to check the query but didn't find where's error come from ?