Thanks for the help ahead of time.
arep
CASE WHEN ClaimsDetail.AllowedAmt = ClaimsDetail.NotCoveredAmt and ClaimsDetail.NotCoveredAmt != 0 then 'Denied'
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Javeed M ShaikhRank #839 · 2.7K reputationPosted Apr 16, 2013, 5:53 PM EDT
Jignesh TrivediRank #16 · 50.3K reputationPosted Apr 16, 2013, 7:56 PM EDT
you have put "Else in wrong place.
try...
CASE WHEN (ClaimsDetail.AllowedAmt = ClaimsDetail.NotCoveredAmt and ClaimsDetail.NotCoveredAmt != 0) then 'Denied'
WHEN (ClaimsDetail.NetAmt != 0 or ClaimsDetail.CopayAmt != 0 or ClaimsDetail.DeductAmt != 0or (ClaimsDetail.OICPaidAmount != 0 and ClaimsDetail.AllowedAmt != ClaimsDetail.NotCoveredAmt))then 'Paid'
WHEN (ClaimsDetail.AllowedAmt = ClaimsDetail.NotCoveredAmt and ClaimsDetail.NotCoveredAmt != 0) then 'Denied'
WHEN (ClaimsDetail.NetAmt != 0 or ClaimsDetail.CopayAmt != 0 or ClaimsDetail.DeductAmt != 0 or (ClaimsDetail.AllowedAmt != 0 and ClaimsDetail.AllowedAmt != ClaimsDetail.NotCoveredAmt)
or (ClaimsDetail.OICPaidAmount != 0 and ClaimsDetail.NotCoveredAmt = 0)) then 'Paid' end as ClaimStatus
syntax is
Case When (condition) then result
when (condition) then result
....
else result end
hope this will help you.
A RepaskyRank #8,108 · 228 reputationPosted Apr 16, 2013, 8:04 PM EDT
It worked. I think all the logic is correct.
Thanks a lot.
I did not want to do this in code, because I have a nice routine that take the datareader and creates any query into a comma delimited file.
arep
A RepaskyRank #8,108 · 228 reputationPosted Apr 18, 2013, 6:58 AM EDT
arep
Javeed M ShaikhRank #839 · 2.7K reputationPosted Apr 18, 2013, 7:06 AM EDT
CASE ColumnName
WHEN 'condition1' THEN '1'
WHEN 'condition2' THEN '2'
ELSE '9999'
END,
Jignesh TrivediRank #16 · 50.3K reputationPosted Apr 18, 2013, 7:30 PM EDT
use can also use ISNULL(result , default value)
ISNULL((CASE WHEN (ClaimsDetail.AllowedAmt = ClaimsDetail.NotCoveredAmt and ClaimsDetail.NotCoveredAmt != 0) then 'Denied'
WHEN (ClaimsDetail.NetAmt != 0 or ClaimsDetail.CopayAmt != 0 or ClaimsDetail.DeductAmt != 0or (ClaimsDetail.OICPaidAmount != 0 and ClaimsDetail.AllowedAmt != ClaimsDetail.NotCoveredAmt))then 'Paid'
WHEN (ClaimsDetail.AllowedAmt = ClaimsDetail.NotCoveredAmt and ClaimsDetail.NotCoveredAmt != 0) then 'Denied'
WHEN (ClaimsDetail.NetAmt != 0 or ClaimsDetail.CopayAmt != 0 or ClaimsDetail.DeductAmt != 0 or (ClaimsDetail.AllowedAmt != 0 and ClaimsDetail.AllowedAmt != ClaimsDetail.NotCoveredAmt)
or (ClaimsDetail.OICPaidAmount != 0 and ClaimsDetail.NotCoveredAmt = 0)) then 'Paid' end),0) as ClaimStatus
this will return 0 value if your expression return null value.
hope this will help you.