select A.colu1,sum(C.colu2)
from table1 A,table2 B,table3 C
where A.colu2=B.colu1 and B.colu2=C.colu1
group by A.colu1;
语句语法没问题,只是结果可能不是你想要的,sum(C.colu2)不是2.5+4.6,而应该是2*(2.5+4.6)改为
select A.colu1,sum(C.colu2)
from table1 A,(select distinct colu1,colu2 from table2) B,table3 C
where A.colu2=B.colu1 and B.colu2=C.colu1
group by A.colu1;
from table1 A,table2 B,table3 C
where A.colu2=B.colu1 and B.colu2=C.colu1
group by A.colu1;
语句语法没问题,只是结果可能不是你想要的,sum(C.colu2)不是2.5+4.6,而应该是2*(2.5+4.6)改为
select A.colu1,sum(C.colu2)
from table1 A,(select distinct colu1,colu2 from table2) B,table3 C
where A.colu2=B.colu1 and B.colu2=C.colu1
group by A.colu1;
(select A.colu1,C.colu2
from table1 A,table2 B,table3 C
where A.colu2=B.colu1 and B.colu2=C.colu1) a
group by a.colu1
不知道你具体想作什么,sql语句还是要自己测试的.
CO SUM(C.COLU2)
-- ------------
a1 5