如何抽取前30的数据汇总项目,剩余的加和列为其他(99),在RDLC报表上作为饼图显示出来

来源:互联网 发布:淘宝上靠谱的古琴店 编辑:程序博客网 时间:2024/04/28 10:46

获取数据集:

declare @pp int declare @pp1 int declare @pp2 int select @pp1=sum(Quantity) from [Order Details] select @pp=sum(total) from ( SELECT TOP (5) ProductID, SUM(Quantity) AS total FROM [Order Details] GROUP BY ProductID order by SUM(Quantity) desc)  a select @pp2=@pp1-@pp select * from( SELECT TOP (30) ProductID, SUM(Quantity) AS total FROM [Order Details] GROUP BY ProductID order by SUM(Quantity) desc) b union select '99',(select @pp2)

原创粉丝点击