是否可以在 SSRS 中水平显示此数据?
Is it possible to display this data horizontally in SSRS?
我有一个 table 正在加入另一个 table,看起来像这样:
Id Score Total
1 10 30
1 7 30
1 13 30
2 14 27
2 10 27
2 3 27
我希望能够在 SSRS 中像这样显示这些数据:
Id 1 2 3 Total
1 10 7 13 30
2 14 10 3 27
这可以做到吗?如何做到?
你可以使用矩阵来做到这一点。
您可以为数据集中的每个 ID 添加行标识符(假设您可以修改数据集,因为您连接了 2 个表)。以下代码适用于 SQL 服务器 (T-SQL)。
Select Id, Score, row_number() over (partition by id order by score) ident
from table
输出:
Id Score Ident
1 10 1
1 7 2
1 13 3
2 14 1
2 10 2
2 3 3
不需要总计字段,您可以将其添加到矩阵中 (Right Click on ColumnGroup>Add Total>After
)。
在 Matrix 中使用上述查询,如下所示。
我有一个 table 正在加入另一个 table,看起来像这样:
Id Score Total
1 10 30
1 7 30
1 13 30
2 14 27
2 10 27
2 3 27
我希望能够在 SSRS 中像这样显示这些数据:
Id 1 2 3 Total
1 10 7 13 30
2 14 10 3 27
这可以做到吗?如何做到?
你可以使用矩阵来做到这一点。
您可以为数据集中的每个 ID 添加行标识符(假设您可以修改数据集,因为您连接了 2 个表)。以下代码适用于 SQL 服务器 (T-SQL)。
Select Id, Score, row_number() over (partition by id order by score) ident
from table
输出:
Id Score Ident
1 10 1
1 7 2
1 13 3
2 14 1
2 10 2
2 3 3
不需要总计字段,您可以将其添加到矩阵中 (Right Click on ColumnGroup>Add Total>After
)。
在 Matrix 中使用上述查询,如下所示。