很确定我已经通过使用以下作为报表的数据集并在报表布局中使用矩阵来解决这个问题。
基本上我做了上面shahkalpesh所说的......“用于显示报告的查询可以将此字段作为计算列。”
select
'Avg' as LocationID,
'Avg' as Description,
AccountDesc,
@PayrollYear as Year,
@PayrollMonth as Month,
avg(s.TotalHrs) as TotalHrs,
avg(s.Amount) as Amount from
(
select LocationID, 'Avg' as Description, AccountDesc,
@PayrollYear as Year, @PayrollMonth as Month,
sum(TotalHrs) as TotalHrs,
sum(Amount) as Amount from vwPayroll
where LocationID in (select value from dbo.ParmsToList(@PayrollLocIds))
and Year = @PayrollYear and Month = @PayrollMonth
group by LocationID, AccountDesc, Year, Month
) as s
group by AccountDesc
union all
select
LocationID,
Description,
AccountDesc,
Year,
Month,
Sum(TotalHrs) as TotalHrs,
Sum(Amount) as Amount
from vwPayroll
where LocationID in (select value from dbo.ParmsToList(@PayrollLocIds))
and Year = @PayrollYear and Month = @PayrollMonth
group by LocationID, Description, AccountDesc, Year, Month