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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T16:34:59+00:00 2026-06-03T16:34:59+00:00

I am working on a cancer database and I have one column with the

  • 0

I am working on a cancer database and I have one column with the date of a patient’s local recurrence (if they had one), and another column with the date of a patient’s distant recurrence (if they had one). I want to create another column that consists of the date of FIRST recurrence, regardless of whether it was local or distant. I’m not sure how to proceed because some patients only had local or only had distant, and thus many fields are “NULL”. Here’s an example of what I’m looking to do:

Date_Local     Date_Distant     Date_Any
2010-08-01     2009-05-25       2009-05-25
NULL           2001-01-07       2001-01-07
1999-12-12     NULL             1999-12-12
NULL           NULL             NULL
  • 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-03T16:35:02+00:00Added an answer on June 3, 2026 at 4:35 pm

    Assuming your already added the column with an ALTER TABLE statement, you would populate it using a CASE statement in the UPDATE query like:

    ALTER TABLE cancertable ADD Date_Any DATE AFTER Date_Distant;
    
    UPDATE cancertable SET Date_Any = 
      CASE
        WHEN Date_Local IS NOT NULL AND Date_Local <= Date_Distant THEN Date_Local
        WHEN Date_Distant IS NOT NULL AND Date_Distant < Date_Local THEN Date_Distant
        ELSE NULL
      END
    

    The above statement will update all rows since it has no WHERE clause. Before doing the UPDATE, test it out with a SELECT to make sure it looks like you expect:

    SELECT *,
      CASE
        WHEN Date_Local IS NOT NULL AND Date_Local <= Date_Distant THEN Date_Local
        WHEN Date_Distant IS NOT NULL AND Date_Distant < Date_Local THEN Date_Distant
        ELSE NULL
      END AS Date_Any
    FROM cancertable
    

    Consider, however, whether you really even need another column added though. Depending on how often you intend to query this, you might just create a view using the SELECT statement above instead, so the Date_Any value will be “live”.

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

Sidebar

Related Questions

I have a gridview that imports data from a remote database, this is working
I have a working WinForm that handles the search functionality in my customer database.
I have an application that I am working on that will query a database
Working on a website that has Employee and Branch entities, using a database table
Working on joining up two legacy DB systems into new database where I can
I'm creating a basic database application in WPF, and I have started using the
Ok So Basically I have made MySQL table on PhpMyAdmin. It's on local host,
I have the AlertView working perfectly with a cancelButtonTitle:@Cancel and otherButtonTitles:nil. My question is
I'm working on an application which list movies from a database. Except for general
I'm currently working on a Database which requires the following functionality: For example given

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.