日期:2014-05-18 浏览次数:20589 次
create table ta (yhbh char(5), ye decimal(5,2)) insert into ta select '001', 1.12 union all select '002', 1.23 create table tb (yhbh char(5), sbbh char(5), ye decimal(5,2)) insert into tb select '001', '01', 0 union all select '001', '02', 0 union all select '002', '03', 0 union all select '002', '04', 0 update tb set tb.ye=ta.ye from tb inner join ta on tb.yhbh=ta.yhbh where tb.sbbh in (select min(sbbh) from tb group by yhbh) select * from tb yhbh sbbh ye ----- ----- -------- 001 01 1.12 001 02 0.00 002 03 1.23 002 04 0.00 (4 row(s) affected)