首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > Mysql >

求一SQL,该如何解决

2012-03-01 
求一SQLAccountItemIDCurrencyIDAmount1221012220123101322013210怎么可以输出以下结果AccountItemIDCurre

求一SQL
AccountItemID     CurrencyID     Amount
          12                           2                   10
          12                           2                   20
          12                           3                   10
          13                           2                   20
          13                           2                   10


怎么可以输出以下结果

AccountItemID     CurrencyID     Amount
          12                           2                   30
          12                           3                   10
          13                           2                   30
即先根据AccountItemID分组统计   再根据CurrencyID分组
select   AccountItemID,CurrencyID,sum(Amount)   Amount     from   table   group   by   AccountItemID,CurrencyID     这样写不行的


[解决办法]
select AccountItemID,CurrencyID,sum(Amount) from table group by AccountItemID,CurrencyID
这样呢?应该是可以的啊!
[解决办法]
group by就可以了。

热点排行