【发布时间】:2014-02-26 23:01:28
【问题描述】:
在现有的 SSRS 2008 r2 报告中,我想要一个名为 @hair 的参数,其中用户
can see if the customer purchased one of the following items:
1. hair spray,
2. hair shampoo,
3. Hair color,
4. hair conditioner, or
5. No hair product purchased.
The table is called inventory and the values for the field called hairproduct are
1. hair spray = 'HR',
2. hair shampoo = 'HS',
3. hair color = 'HC',
4. Hair conditionier = 'HD',
5. If hair product is not purchased hairproduct value is null.
这是由于 库存表包含 hairproduct、eyeproduct、faceproduct 等列。如果一个 购买特定产品时,该列将包含一个值。如果客户购买 所有 4 种头发产品和 3 种眼部产品,以及 9 种面部产品,库存表将包含 针对特定客户的 16 列。
在参数窗口中,我可以使用以下命令在参数窗口中显示正确的值 选择窗口:
SELECT DISTINCT IsNull(inventory.hairproduct,'') as hairid,
CASE IsNull(inventory.hairproduct,'')
WHEN 'HR' then 'hair spray'
WHEN 'HS' then 'hair shampoo'
WHEN 'HC' then 'Hair color'
WHEN 'HC' then 'hair conditioner'
WHEN '' then 'No hair product purchased'
FROM Inventory
**注意@hairproduct 参数允许空值,也允许多个值。
但是,在 ssrs 2008 r2 报告的主要查询中,我不确定如何更改以下内容 声明选择“未购买任何美发产品”。
当前的 select 语句如下所示:
select customer_id,hairproduct
from inventory where customer_id = @customerid
hairproduct in (@hairproduct)
.
基本上我需要更改与参数@hairproduct 匹配的主查询、数据集,或者可能添加 一个新参数,表示“未购买任何美发产品”,用于报告拥有一种或多种美发产品的客户 购买或没有。
那么你能告诉我和/或告诉我可以解决我的问题的 sql 吗?
【问题讨论】:
-
您是否没有存储所有这些产品名称的表,而不是使用这个长大小写语句来选择产品名称,您可以简单地使用该表来填充产品参数的下拉列表并在参数属性选择要在下拉列表中显示的值。
标签: sql-server tsql reporting-services ssrs-2008