Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9216259
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:22:45+00:00 2026-06-18T02:22:45+00:00

I have a big query that has multiple Joins as below. Now I have

  • 0

I have a big query that has multiple Joins as below.
Now I have to tune this query.

Current Logic is: If AppealOutcome Code = F/D/P then Insert ReAdjustedClaimControlNumber.

I need to change my Logic as: For Disposition F/D/P, When ReAdjustmentId is empty from MonthlyApepalFile, Use AdjustmentID. If AdjustmentId is also Empty, Use ClaimControlNumber.

Can anyone please throw any shortcuts?

Insert into rec.RecoveryClaims (ClaimControlKey, ClaimOutcomeCode, ClaimControlNumber )
select 
             A.ClaimControlKey
             ,ClaimOutcomeCode

            ,CASE   WHEN E.AppealOutcomecode = 'F' THEN E.ReadjustedClaimControlNumber
                    WHEN E.AppealOutcomecode = 'D' THEN E.ReadjustedClaimControlNumber
                    WHEN E.AppealOutcomecode = 'P' THEN E.ReadjustedClaimControlNumber
                    ELSE E.AdjustedClaimControlNumber
                    END  
FROM rec.RecoveryClaims A 
INNER JOIN @ExistingRecoveryClaimControlKey b 
    on a.RecoveryClaimControlKey = b.RecoveryClaimControlKey
INNER JOIN occ.Claims C 
    on c.ClaimControlKey = A.ClaimControlKey
INNER JOIN @OutputRecoveryCases D 
    on D.CaseID = C.CaseId  
INNER JOIN @NewClaimControlNumbers E 
    ON C.CaseId = E.CaseID 
    AND A.ClaimControlKey = E.ClaimControlKey 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T02:22:47+00:00Added an answer on June 18, 2026 at 2:22 am

    You can collapse that CASE statement by using IN:

    ,CASE   WHEN E.AppealOutcomecode IN ('F', 'D', 'P') 
            THEN E.ReadjustedClaimControlNumber
            ELSE E.AdjustedClaimControlNumber
    END 
    

    Next, if I understand your requirements, the next portion would look like:

    ,CASE   WHEN Disposition IN ('F', 'D', 'P') 
            THEN COALESCE(ReAdjustmentId , AdjustmentID, ClaimControlNumber)
    END
    

    EDIT:

    If the strings are empty instead of NULL, you can use NULLIF in conjunction with COALESCE:

    ,CASE   WHEN Disposition IN ('F', 'D', 'P') 
            THEN COALESCE(
                NULLIF(ReAdjustmentId, '') , 
                NULLIF(AdjustmentID, ''), 
                NULLIF(ClaimControlNumber, '')
            )
    END
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a big fat query that's written dynamically to integrate some data. Basically
I have a query that looks like this: select id , int1 , int2
So I have this query written by someone else that I'm trying to refactor,
I have a page that has to render a huge set of query results
I have a big table that has many columns. In different use cases I
I have big system that make my system crash hard. When I boot up,
I have big element at the top of the webpage that sides down with
I have this query: SELECT p.text,se.name,s.sub_name,SUM((p.volume / (SELECT SUM(p.volume) FROM phrase p WHERE p.volume
I have a table that has, among its primary keys, a VARCHAR(16) column that
Hey Guys I have a big problem that I have no Idea why.. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.