SSRS报表SQL

时间:2018-09-25 10:29:45

标签: sql reporting-services report

我的数据如下

Year Period Country     STATUS  COST1  COST2  TOTAL COST
2019 1      Australia   PERM    100    200      300
2019 2      NZ          PERM    200    200      400
2019 3      ASIA        TEMP    400    200      600
2019 4      NZ          TEMP    500    200      700

我想在SSRS报告中显示 我需要如下所示的ROWS中的COLUMN和STATUS的期间,以及数据部分中的总费用

     Period
     1   2    3   4

+ PERM总费用

+温度 当最终用户打开+时,它将显示更多详细信息。但是否则就这样。

       Year        Country            COST1  COST2  TOTAL COST
 PERM  2019 1      Australia             100    200      300
       2019 2      NZ                    200    200      400
 TEMP 2019 3      ASIA                  400    200      600
       2019 4      NZ                    500    200      700

预先感谢

2 个答案:

答案 0 :(得分:0)

您似乎想要条件聚合:

select status,
       sum(case when period = 1 then total_cost else 0 end) as total_cost_1,
       sum(case when period = 2 then total_cost else 0 end) as total_cost_2,
       sum(case when period = 3 then total_cost else 0 end) as total_cost_3,
       sum(case when period = 4 then total_cost else 0 end) as total_cost_4
from t
group by status;

答案 1 :(得分:0)

使用SSRS中的矩阵,您可以将行组设置为基于“期间”和“状态”,而无需添加其他数据集。

将“期间”用于列分组,因此该字段将根据“期间”值扩展为4列。 enter image description here

结果: enter image description here 这样,您可以将以下详细信息放在同一表格中,并将其隐藏,直到用户切换为止。