我有一张桌子,我想在2014年的SSRS-2014中报道一下。
一张简约版的表格:-
TABLE_NAME FEE_NAME FEE_VALUE
PDE 1st year 100.00
PDE 2nd year 120.00
PDE 3rd year 130.00
PDE 4th year 140.00
PDE 5th Year 150.00
PGB 1st year 500.00
PGB 2nd year 520.00
PGB 3rd year 530.00
PGB 4th year 440.00
PGB 5th Year 850.00
PUS 1st year 100.00
PUS 2nd year 120.00
PUS 3rd year 130.00
PUS 4th year 140.00
PUS 5th Year 150.00
PCA 1st year 100.00
PCA 2nd year 120.00
PCA 3rd year 130.00
PCA 4th year 140.00
PCA 5th Year 150.00
PJP 8th year 600.00
PJP 10th year 820.00
PJP 11th year 40.00
PJP 12h year 140.00
PJP 14th Year 750.00我如何显示数据,使其是:-
Table Name 1st year 2nd year 3rd year 4th year 5th year 6th year 7th year 8th year 9th year 10th year 11th year 12 year 13th year 14th year
PDE 100.00 120.00 130.00 140.00 150.00
PGB 500.00 520.00 530.00 440.00 850.00
PJP 600.00 820.00 40.00 140.00 750.00诸若此类。
年度专栏将从1到20不等,而且每年都不会有一个值。
我试过用:-
=Lookup(ReportItems!Textbox3.Value, Fields!FEE_NAME.Value, Fields!FEE_DIS1.Value, "Fees")若要使用SSRS表的标题行中的年份从数据集中查找FEE_NAME,但我将为数据集中的每个条目获得一行,但每行显示相同(正确)值。
我试过在SQL中使用CASE :-
CASE WHEN FEES.FEE_NAME = '3rd year' THEN FEE_VALUE END AS [3rd year],同样,我得到我想要的值,然后为其余的TABLE_NAME行空行。
我还查看了Pivot (SQL)和矩阵( SSRS )表,但是我只想返回相应的费用值并在相关的年份列中显示它,而根据我到目前为止所读到的数据,Pivot和SSRS需要一个集合。
希望这是有意义的。
干杯。
发布于 2019-12-02 16:48:14
您可以在SQL中或使用SSRS中的矩阵表来执行此操作。通常,我更喜欢在SQL中这样做,但这对其他人来说并不是最方便的。您是正确的,因为您需要使用具有任何类型的枢轴功能的聚合函数。在您的情况下,您应该使用sum()聚合。
虽然这听起来有点违背直觉,但它工作得很好,因为每个fee_name这里只有一个条目。您最终得到的是一个值列表,其中列表中唯一的内容是所需的值。像,[10]这样的列表将与10相加。
https://dba.stackexchange.com/questions/254570
复制相似问题