SSRS报告 - 饼图50,60,70,... 100

时间:2014-10-20 18:07:59

标签: reporting-services charts pie-chart

我有以下数据集:

0.806400
0.798166
0.885300
1.000000
0.984850
0.952900
0.951200
0.924050
1.000000
0.630500
0.777000
1.000000
0.949200
0.878400
1.000000
1.000000
0.844800
0.871400

为简单起见,我们假设这些是测试分数。每个考试成绩都属于学生。

我想将这些值放在SSRS报告的饼图中。我想饼图按百分比显示它们。分数将按百分比分组。

90%-100%

80%-90%

70%-80%

饼图会将这些组显示为饼图的切片。然后,我将在饼图上显示每个部分的出现次数。

使用上述数据集,预期结果为:

90% - 100%      10
80% - 90%        5
70% - 80%        2
60% - 70%        1

知道如何实现这个目标吗?

1 个答案:

答案 0 :(得分:0)

假设数据位于名为#temp

的表中
SELECT Score
INTO #temp 
FROM (
SELECT SCORE=0.630500 UNION all
SELECT 0.777000 UNION all
SELECT 0.798166 UNION all
SELECT 0.806400 UNION all
SELECT 0.844800 UNION all
SELECT 0.871400 UNION all
SELECT 0.878400 UNION all
SELECT 0.885300 UNION all
SELECT 0.945600 UNION all
SELECT 0.949200 UNION all
SELECT 0.951200 UNION all
SELECT 0.952900 UNION all
SELECT 0.984850 UNION all
SELECT 1.000000 UNION all
SELECT 1.000000 UNION all
SELECT 1.000000 UNION all
SELECT 1.000000 UNION all
SELECT 1.000000  )X

然后你只需要计算分组以将数据转化为百分位数 - 内部选择就是这样 - 外部选择只会创建显示分组

SELECT StartRange
        ,CAST(StartRange AS VARCHAR)+ '% - ' + Cast(StartRange+10 AS VARCHAR)+ '%'AS RANGE
        ,Total
FROM (
        SELECT  CAST(CASE WHEN SCORE=1 THEN .9 ELSE SCORE END * 10 AS INT)*10 AS StartRange
                ,COUNT(*) AS total
        FROM #temp
        GROUP BY CAST(CASE WHEN SCORE=1 THEN .9 ELSE SCORE END * 10 AS INT)*10
    )x

给出结果

StartRange  RANGE       Total
60          60% - 70%   1
70          70% - 80%   2
80          80% - 90%   5
90          90% - 100%  10