我創建了一個參數,讓多個選項給用戶:多選擇在報表生成器3
Total Amount = Grand Total
Region 1 = Total Amount for that Region
Region 2 = Total Amount for that Region
Region 3 = Total Amount for that Region
Region 4 = Total Amount for that Region
地區1〜4的偉大工程,但是當我選擇總量我得到的金額不正確。
有人可以告訴我我做錯了請。
主數據集
SELECT OccupancyDetail.CalendarYear, OccupancyDetail.CalendarMonth, SUM(OccupancyDetail.No_of_Nights) AS No_of_Nights,
SUM(OccupancyDetail.Capacity) AS Capacity,Site.BDM,Site.Region
FROM OccupancyDetail INNER JOIN
Site ON OccupancyDetail.Site_Skey = Site.Site_Skey
WHERE (OccupancyDetail.ReferenceDate = convert(Date,getdate()))
AND
CASE WHEN @Time = 'YEAR' THEN CAST(CalendarYear as varchar(4)) else
CalendarMonth + ' ' + CAST(CalendarYear as varchar(4)) end in (@Dates)
GROUP BY OccupancyDetail.ReferenceDate, OccupancyDetail.CalendarYear, OccupancyDetail.CalendarMonth,Site.BDM, Site.Region
Time Dataset
select DateChoice FROM
(select distinct CalendarYear, 1 as MonthNumber,CAST(CalendarYear as varchar(4)) as DateChoice from Time
where @Time = 'YEAR'
union all
select Distinct CalendarYear, MonthNumber,CalendarMonth + ' ' + CAST(CalendarYear as varchar(4)) as DateChoice from Time where @Time = 'MONTH') as QRYDATA
ORDER BY CalendarYear,MonthNumber
BDM數據集
SELECT DISTINCT BDM
FROM Site
你能舉個例子嗎? – Chepene 2013-03-06 14:01:53