在 SSRS 2008 R2 中选择参数中的一个或所有值
Selecting either one or ALL the values in a parameter in SSRS 2008 R2
我正在 SSRS 中进行报告项目。我有一个名为“customer”的参数。此参数的值现在由 sql 查询填充。我想限制此参数,以便用户应该能够 select 一个客户 或 所有客户 。不应该 select 2 或 3 个客户。
在您的参数列表中有一个名为 All Customers
的选项,该选项已排序,因此位于参数列表的顶部。
如果您手动添加参数选项,这种排序很容易。如果它是 data-driven 您可以在参数值数据集中执行 union all
以获得正确的顺序:
select <Unique value that matches your customer ID type> as Value
,'All Customers' as Label
,1 as SortOrder
union all
select CustomerID as Value
,CustomerName as Label
,2 as SortOrder
from CustomerTable
order by SortOrder
,Label
然后在您的查询中,您只需添加处理这个新 All
值的逻辑:
select Columns
from Tables
where CustomerID = @Customer
or @Customer = <Unique value that matches your customer ID type>
我正在 SSRS 中进行报告项目。我有一个名为“customer”的参数。此参数的值现在由 sql 查询填充。我想限制此参数,以便用户应该能够 select 一个客户 或 所有客户 。不应该 select 2 或 3 个客户。
在您的参数列表中有一个名为 All Customers
的选项,该选项已排序,因此位于参数列表的顶部。
如果您手动添加参数选项,这种排序很容易。如果它是 data-driven 您可以在参数值数据集中执行 union all
以获得正确的顺序:
select <Unique value that matches your customer ID type> as Value
,'All Customers' as Label
,1 as SortOrder
union all
select CustomerID as Value
,CustomerName as Label
,2 as SortOrder
from CustomerTable
order by SortOrder
,Label
然后在您的查询中,您只需添加处理这个新 All
值的逻辑:
select Columns
from Tables
where CustomerID = @Customer
or @Customer = <Unique value that matches your customer ID type>