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

SSRS: Use parameter selection as a condition in Query

如何在 SSRS 查询中使用参数值作为条件..

参数:

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)

在此处使用条件来显示客户

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

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)