[英]How to use an AND LIKE parameter in an SSRS report with an additional OR option?
I have a Dataset Query in SSRS as follows 我在SSRS中有一个数据集查询,如下所示
SELECT * FROM TableName
WHERE Account_Code LIKE @Department+'%'
This is so that the SSRS report is able to provide a drop-down of specified available departments based on the first letter of the Account Code(s) in the Account_Code table. 这样一来,SSRS报告便可以根据Account_Code表中帐户代码的首字母提供指定的可用部门的下拉列表。
I have set the @Department
parameter in SSRS Report Builder with specified available values as shown below... 我已经在SSRS报表生成器中使用指定的可用值设置了
@Department
参数,如下所示...
However, I need Department 3 to be based on two criteria (ie with an Account_Code beginning with 'C' or 'D'). 但是,我需要部门3基于两个条件(即,以“ C” 或 “ D”开头的Account_Code)。 Entering the expression 'C OR D' in parameter properties does not work.
在参数属性中输入表达式“ C OR D”无效。 Do I need to re-think the dataset query itself or can this be done in SSRS parameters with just my LIKE
@Department
clause? 我是否需要重新考虑数据集查询本身,还是可以仅使用LIKE
@Department
子句在SSRS参数中完成此操作?
You could set the third value to [cd]
. 您可以将第三个值设置为
[cd]
。 See the example below. 请参见下面的示例。
DECLARE @Department varchar(10)
SET @Department = '[c-D]'
CREATE TABLE #Test (Account_Code char(2))
INSERT INTO #Test(Account_Code) VALUES
('CA'),
('CB'),
('DA'),
('DB'),
('AZ'),
('AY'),
('BZ'),
('BY')
SELECT *
FROM #Test
WHERE Account_Code LIKE @Department + '%'
DROP TABLE #Test
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.