SSRS——在 SQL Where 子句中使用 Case 语句

SSRS – Using a Case Statement in a SQL Where Clause

下面是我的代码,我希望使用 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 @placementenddate

sample 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

如果我没理解错的话,有几种方法可以做到这一点:

您可以在 SSRS 中创建一个参数,其中包含您希望能够按指定过滤的值。如果要使用少量永不更改的值,这将很有用。然后可以使用此参数过滤 where 子句中的主查询,方法是使用

where ap.PlacementVerificationMethod = @Parameter

where ap.PlacementVerificationMethod  in (@Parameter)

第二个用于多选参数

您还可以在 Tablix 的主报表正文中使用分组。如果按字段 "Placement Method" 分组,则可以设置子组(可能按 EntityID 分组)的可见性,以通过放置方法文本框切换。这允许您展开组以在需要时显示更多详细信息。