我有一个搜索问题的(Oracle SQL)查询:(简化)
select a.date, (a.counter1 + c.counter) / (c.counter1 - a.counter1) percentdiferent
--daily table is agregated to ocupy less space and be faster when searching for the total counters for a day
from dailytable a
join (
--the nonaggregated table has values for each minute
select trunc(b.date) date, sum(counter1) counter1
from minutetable b
where trunc(b.datea) = a.date
group by trunc(b.date)
) c
on c.date = a.date and c.counter1 <> a.counter1
where percentdiferent > 5
要纠正这些问题,我需要执行一个过程:
exec aggregate(tablename, date)
程序经常变化,我有不止一张桌子。有没有办法做类似的事情
with checktables as (
--above code
)
select date
from checktables
group by date
if result > 0
for each result
exec aggregate(tablename,date)
show results
?