日期:2014-05-17 浏览次数:21023 次
insert into tb2
select
id ,
name ,
sum(decode(value,0,1,0)) succ ,
sum(decode(value,0,0,1)) fail
from tb1
group by id ,name
order by id ,name
merge into tb2
using tb1
on(tb1.id=tb2.id and tb1.name=tb2.name)
when matched then
update tb2
set (succ,fail)=(select a.succ,a.fail from(
select id , name , sum(decode(value,0,1,0)) succ ,
sum(decode(value,0,0,1)) fail
from tb1
group by id ,name
order by id ,name)a);
when not matched then
insert into tb2
select id ,name ,sum(decode(value,0,1,0)) succ ,sum(decode(value,0,0,1)) fail
from tb1
group by id ,name
order by id ,name;
merge into tb2
using tb1
on(tb1.id=tb2.id and tb1.name=tb2.name)
when matched then
update tb2
set (succ,fail)=(select a.succ,a.fail from(
select id , name , sum(decode(value,0,1,0)) succ ,
&nbs