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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:43:13+00:00 2026-05-25T10:43:13+00:00

In the query similar to this: SELECT COLUMN1, CASE WHEN 1=2 THEN COLUMN2 END

  • 0

In the query similar to this:

SELECT 
  COLUMN1,
  CASE WHEN 1=2 THEN
    COLUMN2
  END AS "COLUMN2"
FROM
  TABLE1

…it appears to always return COLUMN2 in the dataset with NULL values in it. I’d like to avoid that. Basically, in certain conditions one of the columns I am selecting is not applicable, therefore I don’t want to select it at all. I know how to “hide” it in code, but I would like to achieve this in the database procedure if at all possible without overcomplicating the query.

  • 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-25T10:43:14+00:00Added an answer on May 25, 2026 at 10:43 am

    That is not possible. A query has to have a fixed set of columns that it returns (drawing from a known set of tables). That part is not dynamic, it needs to be known at “compile-time”.

    You need to remove the column in your application (or have multiple queries, potentially generated dynamically in client code).

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

Sidebar

Related Questions

I'm trying to execute a query that looks similar to this: SELECT <columns> FROM
I have a multi-table query, similar to this (simplified version) SELECT columns, count(table2.rev_id) As
I currently have a query similar to: SELECT users.fname, users.lname, sales.date FROM users LEFT
I have a query that looks something like this: select xmlelement(rootNode, (case when XH.ID
I have a query similar to the following: SELECT CASE WHEN (GROUPING(Name) = 1)
I want to create a MyQSL Query similar to SELECT person, city FROM mytable
This query: select * from op.tag where tag = 'fussball' Returns a result which
I have a query SELECT * FROM table1 WHERE documentId in ( --select items
How can I write a query similar to this one in LINQ to SQL
I am doing a query that converts rows to columns similar to this post

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.