select AccountItemID,CurrencyID,sum(Amount) from xxx group by AccountItemID,CurrencyID
SQL Server下应该是这样,MySQL不清楚,应该意思差不多吧
select AccountItemID,CurrencyID,sum(Amount) as Amount from table1 group by AccountItemID,CurrencyID;
select AccountItemID,CurrencyID,sum(Amount) Amount from table group by AccountItemID,CurrencyID 肯定没有问题了
create table aa (AccountItemID int(11), CurrencyID int(11), Amount int(11)) engine=innodb charset=utf8; insert into aa values('12','2','10'),('12','2','20'),('12','3','10'); select AccountItemID,CurrencyID,sum(Amount) from aa group by AccountItemID,CurrencyID; ================query result(2 records) AccountItemID CurrencyID sum(Amount) 12 2 30 12 3 10
select AccountItemID,CurrencyID,sum(Amount) as Amount from 表名 group by AccountItemID,CurrencyID
肯定没有问题了
insert into aa values('12','2','10'),('12','2','20'),('12','3','10');
select AccountItemID,CurrencyID,sum(Amount) from aa group by AccountItemID,CurrencyID;
================query result(2 records)
AccountItemID CurrencyID sum(Amount)
12 2 30
12 3 10
from 表名
group by AccountItemID,CurrencyID