Quantcast
Channel: SQL Server Reporting Services, Power View forum
Viewing all articles
Browse latest Browse all 10045

Case statement in where clause

$
0
0

I'm trying to create a SSRS report for pulling employee records.

Depending on the parameter value for @workgroup at run-time, I want the query to select records based on specific status. I tried the below case statement in where clause but it is not working. 

-------------------------------------------

FROM
EMPLOYEE E

LEFT OUTER JOIN DEPT D
ON E.DEPT = D.CODE

LEFT OUTER JOIN ORGUNIT O
ON O.CODE = E.ORGUNIT

LEFT OUTER JOIN JOB J
ON E.JOB = J.CODE

WHERE

E.FLDWORKGRP = @workgroup AND

CASE WHEN @workgroup = 'Value' THEN E.STATUS = 'A' ELSE
E.STATUS IN ('A','N','LOA','P','D') END

ORDER BY E.LNAME

Let me know if there is any other way to do this. Thanks in advance for your help.


Viewing all articles
Browse latest Browse all 10045

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>