select ID,vip_accounts, MAX(THprices) THprices, MAX(SendGoodsPrice) SendGoodsPrice, MAX(balanceMoney) balanceMoney from T_isok_order_ALL_Account where vip_accounts='素素' group by ID,vip_accounts
------解决方案-------------------- 分组group by vip_accounts ------解决方案--------------------
select id,vip_accounts,isnull(THprices,0)+isnull(SendGoodsPrice,0)+isnull(balanceMoney,0) from 表
数值型的可以直接加和 ------解决方案-------------------- 修改一下:
select id,vip_accounts,max(isnull(THprices,0)) as THprices,max(isnull(SendGoodsPrice,0)) as SendGoodsPrice max(isnull(balanceMoney,0))) as balanceMoney from 表 group by id,vip_accounts
select min(id)as id,vip_accounts,max(isnull(THprices,0)) as THprices,max(isnull(SendGoodsPrice,0)) as SendGoodsPrice max(isnull(balanceMoney,0))) as balanceMoney from 表 group by vip_accounts
------解决方案--------------------
select min(ID) id, vip_accounts, MAX(THprices) THprices, MAX(SendGoodsPrice) SendGoodsPrice, MAX(balanceMoney) balanceMoney from T_isok_order_ALL_Account group by vip_accounts
------解决方案--------------------
select min(id)as id,vip_accounts,max(isnull(THprices,0)) as THprices,max(isnull(SendGoodsPrice,0)) as SendGoodsPrice max(isnull(balanceMoney,0))) as balanceMoney from 表 group by vip_accounts
按照你这方法,还是有问题,负数是无法出来的
修改一下,把isnull放到max外面,就可以了:
select min(id)as id,vip_accounts,isnull(max(THprices),0) as THprices,isnull(max(SendGoodsPrice),0) as SendGoodsPrice,isnull(max(balanceMoney),0) as balanceMoney from 表 group by vip_accounts