我的报告中有一个名为报告级别的参数,您可以在其中从 4 个选项中进行选择:
公司 BDM 地区站点
我想要做的是:
选择 BDM,这将打开另一个参数调用 BDM 列表(这基于从查询中获取值),但我希望其他参数保持灰色。一旦从 BDM 列表中做出选择,时间和日期参数就会变得可用。
这可能吗?
这些是我的 BDM 列表和区域列表的数据集:
SELECT SiteInfo FROM
((SELECT DISTINCT BDM, Region, SiteName As SiteInfo
FROM Site
WHERE @ReportingLevel = 'BDM'
union all
SELECT DISTINCT BDM, Region, SiteName As SiteInfo
FROM Site
WHERE @ReportingLevel = 'Region' )
union all
SELECT DISTINCT BDM, Region, SiteName As SiteInfo
FROM Site
WHERE @ReportingLevel = 'SiteName') AS QRY2
这是我的主要数据集:
SELECT OccupancyDetail.CalendarYear, OccupancyDetail.CalendarMonth, SUM(OccupancyDetail.No_of_Nights) AS No_of_Nights,
SUM(OccupancyDetail.Capacity) AS Capacity
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)
AND Site.BDM IN (@BDM)
AND Site.Region IN (@Region)
AND Site.SiteName IN (@SiteName)
GROUP BY OccupancyDetail.ReferenceDate, OccupancyDetail.CalendarYear, OccupancyDetail.CalendarMonth
时间数据集
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
我希望你能帮助这是我工作的第三天。
谢谢
韦恩