[英]SSRS – Using a Case Statement in a SQL Where Clause
below is my code, I wish to make a drop down list in ssrs using the case statement options but I don't know how to parametrize case statements. 以下是我的代码,我希望使用case语句选项在ssrs中创建一个下拉列表,但我不知道如何对case语句进行参数化。
select c.EntityID, c.FirstName, c.LastName, (case ap.PlacementVerificationMethod when 107 then 'contact center' when 1 then 'work number/3rd party verification' when 101 then 'Placement call' when 102 then 'walk in/Self report' when 103 then 'Email' when 104 then 'Employer Report' when 105 then 'In person with participant' when 106 then 'In person with employer' else 'unknown' end) as 'Placement method', wh.JobTitle, ap.PlacementDate, p.ProviderName Employer, u.UserName Placementby from AssessEmploymentPlacement ap join users u on AP.PlacementBy = U.EntityID join WorkHistory wh on WH.WorkHistoryID = AP.WorkHistoryID join client c on wh.ClientID =c.EntityID join provider p on WH.ProviderID = P.EntityID join assessment a on AP.AssessmentID = A.AssessmentID where ap.PlacementDate between @placementbegindate and @placementenddatesample table for AssessEmployementPlacement
@ChrisLätta sample table for AssessEmploymentPlacement AssessmentID client placementVerificationmethod 1234 sam null 4567 james 101 2234 don 102 5364 manny 107 6595 jon null 6598 woe 104 5496 kie 105
If I understand correctly, there are a couple of ways to accomplish this: 如果我理解正确,有两种方法可以实现此目的:
You can create a parameter in SSRS with the values you wish to be able to filter by specified. 您可以在SSRS中创建一个参数,并为其指定希望过滤的值。 This is useful if there are a small number of never changing values to use.
如果有少数几个永不更改的值可以使用,这将很有用。 This parameter can then be used to filter the main query in the where clause either by using
然后,可以通过以下方式使用此参数来过滤where子句中的主查询:
where ap.PlacementVerificationMethod = @Parameter
or 要么
where ap.PlacementVerificationMethod in (@Parameter)
The second one is used for multiple selection parameters. 第二个用于多个选择参数。
You can also use grouping in the main report body in a tablix. 您还可以在Tablix的主报表主体中使用分组。 If you group by the field "Placement Method" you can then set the visibility for the subgroup (probably grouped on EntityID) to be toggled by the Placement Method text box.
如果按“放置方法”字段分组,则可以设置要由“放置方法”文本框切换的子组(可能在EntityID上分组)的可见性。 This allows you to expand the group to show more details when wanted.
这使您可以扩展组以在需要时显示更多详细信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.