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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T17:19:13+00:00 2026-05-31T17:19:13+00:00

I am selecting into an existing column C from column A if it has

  • 0

I am selecting into an existing column C from column A if it has a value greater than zero. If not then I want to populate it with column B. It will populate with column A only if column B is zero. If both column A and B have values it always uses B. Any help would be appreciated.

( 
   CASE
       WHEN column A > 0  THEN column A
       ELSE column B                
   END
)

My insert into was correct but my select had the columns reversed which was causing what I thought was an error. Thanks for all of your help. What a noob thing to do.

  • 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-31T17:19:14+00:00Added an answer on May 31, 2026 at 5:19 pm

    Your database of choice will be extremely useful, as it looks like you are already correct in most RDBMS. Just stick exactly what you have already inside of a select:

    --Insert based on select
    --INSERT INTO [TABLETOINSERT] (ColumnToInsert)
    SELECT 
        CASE 
           WHEN ColumnA > 0 THEN ColumnA
           ELSE ColumnB
        END AS NewColumn
    --Or create a table the select
    --INTO [NEWTABLENAME]
    FROM [TABLENAME]
    

    Or update:

    UPDATE [TABLENAME]
    SET NewColumn = 
        CASE 
           WHEN ColumnA > 0 THEN ColumnA
           ELSE ColumnB
        END
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am selecting from a table that has an XML column using T-SQL. I
I'm selecting 1 field from 1 table and storing it into a temp table.
when selecting a column that can contains a NULL value I get an exception
I'm currently inserting a record into a SQL Server Table and then selecting the
I keep forgetting - I am selecting into an output file with terminal MySQL
I am selecting rows from a table, but some of the columns are a
When I try to put some condition value into ContentValues variable, there is inserting
I've run into a situation where I am creating a jQuery object from an
My application launches into a navigation controller. The root view controller has a button
as briefly explained in subject, I need to create a table by selecting existing

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.