日期:2014-05-17 浏览次数:20733 次
create table t ( f1 varchar2(20), f2 varchar2(20), f3 varchar2(30), f4 number, f5 number, f6 number); insert into t values('A','S001','C001',4,3,5); insert into t values('A','S001','C001',4,7,1); insert into t values('B','S001','C001',6,0,1); insert into t values('C','S001','C001',7,4,4); insert into t values('D','S001','C001',6,3,5); insert into t values('E','S001','C001',9,3,8); insert into t values('F','S001','C001',1,2,2);
SELECT SUM(F4),SUM(F5),SUM(F6) FROM (SELECT SUM(DISTINCT F4) AS f4 ,SUM(F5) AS f5,SUM(F6) AS f6 FROM t GROUP BY f1,f2)t /** (沒有資料行名稱) (沒有資料行名稱) (沒有資料行名稱) 33 22 26 **/
------解决方案--------------------
实际测试,请参考: