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 6120167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:38:15+00:00 2026-05-23T15:38:15+00:00

I am having some issues with the below query, I was unsure as to

  • 0

I am having some issues with the below query, I was unsure as to how to modify it to give me the desired output which is detailed further below:

SELECT listup.NodeNumber As Node, listup.Station As Extension,
       CASE WHEN VoiceServer = 1 THEN KeyDescription ELSE '' END AS 'Key1',
       CASE WHEN VoiceServer = 2 THEN KeyDescription ELSE '' END AS 'Key2',
       CASE WHEN VoiceServer = 3 THEN KeyDescription ELSE '' END AS 'Key3',
       CASE WHEN VoiceServer = 4 THEN KeyDescription ELSE '' END AS 'Key4',
       CASE WHEN VoiceServer = 5 THEN KeyDescription ELSE '' END AS 'Key5',
       CASE WHEN VoiceServer = 6 THEN KeyDescription ELSE '' END AS 'Key6',
       CASE WHEN VoiceServer = 7 THEN KeyDescription ELSE '' END AS 'Key7',
       CASE WHEN VoiceServer = 8 THEN KeyDescription ELSE '' END AS 'Key8',
       CASE WHEN VoiceServer = 9 THEN KeyDescription ELSE '' END AS 'Key9',
       CASE WHEN VoiceServer = 10 THEN KeyDescription ELSE '' END AS 'Key10'
  FROM listup
ORDER BY listup.NodeNumber, listup.Station;

The output is as follows:

Node    Extension  Key1   Key2   Key3  etc.
N100    14311   14311                                    
N100    14311       14308                                
N100    14311           14309                            
N100    14311               14314                        
N100    14311                   14412                    
N100    14311                       14535                
N100    14311                           14316            
N100    14311                               14456        
N100    14312   14312                                    
N100    14312       14442                                
N100    14312           14311                            
N100    14312               14314                        
N100    14312                   14456                    
N100    14312                       14309                
N100    14312                           14308            

I was wanting to have it all appear on one line, so flattened as such..
eg.

N100    14311   14311   14308   14309   14314  14412  14535  14316   14456
N100    14312   14312   14442   14311   14314  14456  14309  14308 
  • 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-23T15:38:16+00:00Added an answer on May 23, 2026 at 3:38 pm

    You need to define a GROUP BY clause, and use the MAX aggregate to get the output you want:

      SELECT listup.NodeNumber As Node, listup.Station As Extension,
             MAX(CASE WHEN VoiceServer = 1 THEN KeyDescription ELSE NULL END) AS 'Key1',
             MAX(CASE WHEN VoiceServer = 2 THEN KeyDescription ELSE NULL END) AS 'Key2',
             MAX(CASE WHEN VoiceServer = 3 THEN KeyDescription ELSE NULL END) AS 'Key3',
             MAX(CASE WHEN VoiceServer = 4 THEN KeyDescription ELSE NULL END) AS 'Key4',
             MAX(CASE WHEN VoiceServer = 5 THEN KeyDescription ELSE NULL END) AS 'Key5',
             MAX(CASE WHEN VoiceServer = 6 THEN KeyDescription ELSE NULL END) AS 'Key6',
             MAX(CASE WHEN VoiceServer = 7 THEN KeyDescription ELSE NULL END) AS 'Key7',
             MAX(CASE WHEN VoiceServer = 8 THEN KeyDescription ELSE NULL END) AS 'Key8',
             MAX(CASE WHEN VoiceServer = 9 THEN KeyDescription ELSE NULL END) AS 'Key9',
             MAX(CASE WHEN VoiceServer = 10 THEN KeyDescription ELSE NULL END) AS 'Key10'
        FROM listup
    GROUP BY listup.NodeNumber As Node, listup.Station As Extension
    ORDER BY listup.NodeNumber, listup.Station
    

    NULL is preferable to a zero length string.

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

Sidebar

Related Questions

We are having some major performance issues with SELECT queries out one of our
The code is below but I am having some issues with creating a relative
For the code below, I am having some issues in IE. The second parameter
I'm having an issue with the below query: SELECT Consignments.LegacyID, Consignments.TripDate, Consignments.CollectionName, CASE WHEN
Ok I am still having some issues with this code below. I have received
I am having some redundant primary key issues. I have an Item which contains
I am having some issues with the app engine's bulkloader. Below I have inserted
Having some issues getting my head around the differences between UTF-8, UTF-16, ASCII and
Having some issues with the ... in ObjectiveC. I'm basically wrapping a method and
We've been having some issues with a SharePoint instance in a test environment. Thankfully

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.