Sum数据统计
如图
我想要的效果是
appname appfilename aznum apnum dbnum waz yaz
今日头条 NewsArtic...apk sum(aznum) sum(apnum) p sum(waz) sum(yaz)
58同城 58client...apk sum(aznum) sum(apnum) M sum(waz) sum(yaz)
select appname ,appfilename ,aznum,apnum,DBnum,max(case when InstallState ='未安装' then aznum else 0 end)waz,
max(case when InstallState ='已安装' then aznum else 0 end) yaz from dbo.V_AzApNum where 1=1 group by appname,appfilename ,aznum,apnum,DBnumorder by dbnum desc
[解决办法]
还是不太懂啊,那你的语句不是应该group by appname,appfilename,dbnum?
然后上面该sum的sum,该max的max吗
select appname,appfilename,DBnum,sum(aznum),sum(apnum),max(case when InstallState ='未安装' then aznum else 0 end)waz,
max(case when InstallState ='已安装' then aznum else 0 end) yaz from dbo.V_AzApNum where 1=1 group by appname,appfilename,DBnum
order by dbnum desc
--如果你的语句逻辑正确不需要修改的话,就直接把你的语句去掉order by子句,然后
select appname,appfilename,dbnum,sum(aznum),sum(apnum),sum(waz),sum(yaz)
from (你的语句,去掉order by) as a
group by appname,appfilename,dbnum