insert into B
select a.id,b.cd_zt=(a.cd+a.zt),b.wdk=sum(c.*) from a inner join b on a.id=c.id where month(c.udt)=12 and year(c.udt)=2003 and c.kqid='999'
group by a.id,(a.cd+a.zt)
select a.id,b.cd_zt=(a.cd+a.zt),b.wdk=sum(c.*) from a inner join b on a.id=c.id where month(c.udt)=12 and year(c.udt)=2003 and c.kqid='999'
group by a.id,(a.cd+a.zt)
insert into B
select a.id,(a.cd+a.zt) cd_zt,d.wdk from
(select id ,count(*) as wdk from c
where month(c.udt)=12 and year(c.udt)=2003 and c.kqid='999' group by id) d
inner join a on a.id=d.id