最右边的列是我要添加到报告中的内容。这可以不修改查询以使用像Unpivot这样的东西吗?
Step X Step W Step A Step B Step Y Last Step
---------------------------------------------------------------------
1/21/2013 1/24/2013 1/3/2013 1/5/2013 1/7/2013 Step W
这是朝着正确方向迈出的一步,但似乎只适用于SSRS 2008:http://www.bigator.com/2012/04/26/spothighlight-minimum-and-maximum-values-in-each-row-in-matrix-report-in-ssrs/
答案 0 :(得分:2)
您可以使用UNPIVOT
功能和CROSS APPLY
来获取此信息:
;with cte as
(
select col, value
from yourtable
unpivot
(
value
for col in ([Step X], [Step W], [Step A], [Step B], [Step Y])
) unpiv
)
select [Step X],
[Step W],
[Step A],
[Step B],
[Step Y],
d.col LastStep
from yourtable
cross apply
(
select c1.col
from cte c1
inner join
(
select max(value) MaxDate
from cte
) c2
on c1.value = c2.maxdate
) d