日期:2014-05-17 浏览次数:21152 次
create table a (id number(5),mc varchar2(10),sl number(5)); insert into a values (100,'苹果',1); insert into a values (101,'梨子',3); create table b (id number(5),mc varchar2(10),sl number(5)); insert into b values (100,'苹果',4); insert into b values (101,'梨子',2); create table c (id number(5),mc varchar2(10),sl number(5)); insert into c values (100,'苹果',2); insert into c values (101,'梨子',2); commit; select a.id,a.mc,sum(a.sl+b.sl) s1,sum(c.sl) s2,sum(a.sl+b.sl+c.sl) s3 from a,b,c where a.id=b.id and a.id=c.id group by a.id,a.mc order by a.id id mc s1 s2 s3 ---------------------------------------------- 1 100 苹果 5 2 7 2 101 梨子 5 2 7