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

  • SEARCH
  • Home
  • 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 840015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T05:33:25+00:00 2026-05-15T05:33:25+00:00

Can I refactor the below SQL CASE statements into single for each case ?

  • 0

Can I refactor the below SQL CASE statements into single for each case ?

SELECT 
  CASE RDV.DOMAIN_CODE  WHEN 'L' THEN CN.FAMILY_NAME  ELSE NULL END AS [LEGAL_FAMILY_NAME],
  CASE RDV.DOMAIN_CODE  WHEN 'L' THEN CN.GIVEN_NAME  ELSE NULL END AS [LEGAL_GIVEN_NAME],
  CASE RDV.DOMAIN_CODE  WHEN 'L' THEN CN.MIDDLE_NAMES  ELSE NULL END AS [LEGAL_MIDDLE_NAMES],
  CASE RDV.DOMAIN_CODE  WHEN 'L' THEN CN.NAME_TITLE  ELSE NULL END AS [LEGAL_NAME_TITLE],

  CASE RDV.DOMAIN_CODE  WHEN 'P' THEN CN.FAMILY_NAME  ELSE NULL END AS [PREFERRED_FAMILY_NAME],
  CASE RDV.DOMAIN_CODE  WHEN 'P' THEN CN.GIVEN_NAME  ELSE NULL END AS [PREFERRED_GIVEN_NAME],
  CASE RDV.DOMAIN_CODE  WHEN 'P' THEN CN.MIDDLE_NAMES  ELSE NULL END AS [PREFERRED_MIDDLE_NAMES],
  CASE RDV.DOMAIN_CODE  WHEN 'P' THEN CN.NAME_TITLE  ELSE NULL END AS [PREFERRED_NAME_TITLE]

FROM dbo.CLIENT_NAME CN
JOIN dbo.REFERENCE_DOMAIN_VALUE RDV 
ON CN.NAME_TYPE_CODE = RDV.DOMAIN_CODE AND RDV.REFERENCE_DOMAIN_ID = '7966'
  • 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-05-15T05:33:26+00:00Added an answer on May 15, 2026 at 5:33 am

    No, you will require 8 separate statements as case and other such variants can only be used in a select to modify the results of a single column, not a series of columns.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 495k
  • Answers 495k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Make sure to "rewind" the stream before you return it… May 16, 2026 at 11:15 am
  • Editorial Team
    Editorial Team added an answer use .keydown() or .keyup() see it in action jQuery(function($){ var… May 16, 2026 at 11:15 am
  • Editorial Team
    Editorial Team added an answer I don't know Cairo so I'll delete my answer if… May 16, 2026 at 11:15 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I am writing an addin into Sql Server Management Studio, using the Visual Studio
I'm looking to refactor the below query to something more readable and modifiable. The
The method below called UserCanAccessThisPage is based on the following logic: each user and
How can I re-use chunks of TML markup between pages? I want to refactor
In order to refactor my MATLAB code, I thought I'd pass around functions as
The view below is a container for three user controls, and I started getting
Hope I can explain this somewhat decently, as it's blowing a fuse in my
I've been attempting to refactor a fairly simple three or four page site to
I have installed CodeRush and ReFactor package but i don't see any changes on
Can I use the following across all browsers? <a href=# onclick=doSomething()>Click here.</a> Is this

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.