Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Can someone explain what this doing in the where clause?
@mod char (3),@FromDate datetime,@ToDate datetimeASselect * from ClaimInfo1WHERE CASE When mod = 'I1' then 'I&E' When mod = 'OA' then 'OAS' WHEN RIGHT(Clm, 5) BETWEEN '00000' AND '09980' THEN '01' WHEN RIGHT(Clm, 5) BETWEEN '09981' AND '18170' THEN '02' END = @mod AND PmtDate BETWEEN @fromdate AND @todate and pmtamt >= 50000.00order by pmtamt
yongslee
Starting Member
1 Post
Posted - 2011-11-29 : 17:24:12
Where clause compares input param @mod to the output of CASE statement. The output value of CASE statement can be I&E/OAS/01/02 depending on the specific condition. That is, if ClaimInfo1.mod is I1, use I&E; if ClaimInfo1.mod is OA, use OAS; if right 5 chars in ClaimInfo1.Clm is in 00000-09980 , use 01; and so on.