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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Help understanding stored procedure

Author  Topic 

JJ297
Aged Yak Warrior

940 Posts

Posted - 2011-11-29 : 15:03:45
Can someone explain what this doing in the where clause?



@mod char (3),
@FromDate datetime,
@ToDate datetime


AS
select *

from ClaimInfo1

WHERE 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.00
order 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.
Go to Top of Page

JJ297
Aged Yak Warrior

940 Posts

Posted - 2011-11-29 : 21:06:25
Thanks so much for explaining!!!
Go to Top of Page
   

- Advertisement -