【问题标题】:SSRS: Use parameter selection as a condition in QuerySSRS:使用参数选择作为查询中的条件
【发布时间】:2015-09-07 08:29:09
【问题描述】:

如何在 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)

【问题讨论】:

  • 你能澄清一下'ABC'实际上指的是什么吗?选择“是”时,您期望发生什么? span>
  • 我在“customer.cust_n”字段中有很多值。如果我选择是,我需要在报告结果中包含客户“ABC”,否则不。

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


【解决方案1】:

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

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)

【讨论】:

  • 谢谢,完美。添加 Last "N" Days 后,有什么方法可以在查询中再添加一个过滤器。我需要选择任何一个过滤器日期或过去 n 天..
猜你喜欢
  • 2018-09-28
  • 1970-01-01
  • 2015-12-29
  • 2017-05-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-09-30
相关资源
最近更新 更多