我有一个在 SQL 中运行良好的查询。当我尝试将其引入 SSRS 时,报告要求提供 4 个参数。其中两个参数/变量实际上基于其他两个参数,如下所示:
DECLARE @Q int --SET @Q = 1 -- Quarter
DECLARE @Year int --SET @Year = 2013
DECLARE @STARTDATE varchar(10)
SELECT @STARTDATE = D FROM (
select case @Q
when 1 then '1/1/' + convert(varchar(10),@Year)
when 2 then '4/1/' + convert(varchar(10),@Year)
when 3 then '7/1/' + convert(varchar(10),@Year)
when 4 then '10/1/' + convert(varchar(10),@Year)
end as D
) sd
DECLARE @ENDDATE varchar(10)
SELECT @ENDDATE = D FROM (
select case @Q
when 1 then '3/31/' + convert(varchar(10),@Year)
when 2 then '6/30/' + convert(varchar(10),@Year)
when 3 then '9/30/' + convert(varchar(10),@Year)
when 4 then '12/31/' + convert(varchar(10),@Year)
end as D
) ed
--(ADDITIONAL SQL CONTINUES USING ALL 4 PARAMETERS) ...
如何让 SSRS 只询问前两个参数 ( @Q
, @Year
) 并忽略@StartDate
and ,@EndDate
因为它们是在查询中计算的?