SSRS:使用参数选择作为Query中的条件

时间:2015-09-07 08:29:10

标签: sql-server reporting-services ssrs-2008-r2 ssrs-tablix

如何在SSRS查询中将参数值用作条件  enter image description here

参数:

date_from :datetime 
date_to :datetime
cust: text (label:Yes , Value :Y & Label :No , value:N)

查询:

SELECT dbo.incident.incident_ref,Customer.cust_n,incident.date_logged 
FROM incident
INNER JOIN Customer ON incident.incident_id = Customer.cust_id
WHERE incident.date_logged BETWEEN @date_from AND DATEADD(day, 1, @date_to)

我会根据dropdownlist中的选择(包括ABC)在此处使用条件来显示客户

1 个答案:

答案 0 :(得分:0)

您可以尝试将查询更改为:

SELECT dbo.incident.incident_ref,Customer.cust_n,incident.date_logged 
FROM incident
INNER JOIN Customer ON incident.incident_id = Customer.cust_id
WHERE 
    incident.date_logged BETWEEN @date_from AND DATEADD(day, 1, @date_to) and
    customer.cust_n = (case when @cust = 'N' and customer.cust_n = 'ABC' then NULL else customer.cust_n end)