SSRS参数设置

时间:2015-07-06 21:24:48

标签: reporting-services

我是SSRS的新手,想要一些帮助设置参数

select cast(i.invoicedatetime as date) as Date, oi.DepartmentID, departmentname, SubDepartmentName, sum(Quantity*each*UnitPrice-o.DiscountAmount-i.DiscountAmount) as Sales
from InvoiceInfo i, 
    orderinfo o, 
    OrderItemInfo oi, 
    DepartmentInfo d, 
    SubDepartmentInfo s
where i.InvoiceID = o.InvoiceID
and o.orderid = oi.OrderID
and oi.DepartmentID = d.DepartmentID
and oi.SubDepartmentID = s.SubDepartmentID
group by DepartmentName, SubDepartmentName, InvoiceDateTime, oi.DepartmentID
order by DepartmentName

我想要一个名为的部门:具有以下部门可用值的部门:1,2,3

我的查询看起来像这样得到数据:

其中oi.departmentid in(1,2,3)

我不知道如何设置参数以得到相同的结果。

2 个答案:

答案 0 :(得分:2)

这基本上就是你做的,转到参数并添加参数,选择类型数字,选择,允许多个。在可用值下,选择指定值,并列出每个值。 note标签是用户将看到的内容,而Value是将通过SQL的内容。在你的代码中也改变它

select cast(i.invoicedatetime as date) as Date, oi.DepartmentID, departmentname, SubDepartmentName, sum(Quantity*each*UnitPrice-o.DiscountAmount-i.DiscountAmount) as Sales
from InvoiceInfo i, 
    orderinfo o, 
    OrderItemInfo oi, 
    DepartmentInfo d, 
    SubDepartmentInfo s
where i.InvoiceID = o.InvoiceID
and o.orderid = oi.OrderID
and oi.DepartmentID in (@Departments)
and oi.SubDepartmentID = s.SubDepartmentID
group by DepartmentName, SubDepartmentName, InvoiceDateTime, oi.DepartmentID
order by DepartmentName

注意一些事情,你的参数名称没有@但你的代码必须。 SSRS也区分大小写,所以一定要匹配。

答案 1 :(得分:1)