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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T23:03:17+00:00 2026-05-17T23:03:17+00:00

I have a database table like that :- Table1 Column1 : Varchar(50) Column2 :

  • 0

I have a database table like that :-

Table1

Column1 : Varchar(50)
Column2 : Varchar(50)
Column3 : Boolean
Column4 : Varchar(50)
Column5 : Varchar(50)

I would like to create a dummy column -or add a new column to the table- when running a SQL statement so that the value is that column will hold a string indicating the satus of the row item depeing on more than one of these columns. I mean wether these columns have Null values or not.

A logical way to represent that:-

Select switch DummyColumn

"status1" Case column1 IS NOT NULL
"status2" Case column2 IS NOT NULL
"status3" Case column3 IS NOT NULL
"status4" Case column1 IS NOT NULL AND column2 IS NOT NULL
"status5" Case column2 IS NOT NULL AND column3 IS NULL
"status6" Case column2 IS NOT NULL OR column3 IS NOT NULL

From Table1;

In Business Logic, I can say I want to make display a string indicating the status of an Item in the database depeding on many other status columns which may be boolen or string and this status can have many values according to the values stored in these table columns.

My database engine is Sybase.

How I can build my SQL query to do that ? what may be this matter called ? How I can find or search for that ? I do not know in what topic I may find this ? I search about Merging, Concatening, Replacing, NVL, and Union but i do not find what I seek for..

Thanks in Advance and I hope that I express my question well and that it is a duplicate and I hope to find a good answer for it as soon as possible ..

  • 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-17T23:03:18+00:00Added an answer on May 17, 2026 at 11:03 pm

    There’s more than one way to skin a cat, this is one of them.

    SELECT  t.Column1
            , t.Column2
            , t.Column3
            , t.Column4        
            , t.Column5
            , t.Column6
            , COALESCE(Status1, Status2, Status3, Status4, Status5, Status6) AS DummyColumn
    FROM    (
              SELECT  *
                      , CASE WHEN Column1 IS NOT NULL THEN 'status1' ELSE NULL END AS Status1
                      , CASE WHEN Column2 IS NOT NULL THEN 'status2' ELSE NULL END AS Status2
                      , CASE WHEN Column3 IS NOT NULL THEN 'status3' ELSE NULL END AS Status3
                      , CASE WHEN Column1 IS NOT NULL AND Column2 IS NOT NULL THEN 'status4' ELSE NULL END AS Status4
                      , CASE WHEN Column2 IS NOT NULL AND Column3 IS NULL THEN 'status5' ELSE NULL END AS Status5
                      , CASE WHEN Column2 IS NOT NULL OR Column3 IS NOT NULL THEN 'status6' ELSE NULL END AS Status6
              FROM    Table1
            ) t
    

    Note that this works using SQL Server but as there are no arcane constructions involved, it should be relatively easy to convert this to SyBase.

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

Sidebar

Related Questions

I have a large database and would like to select table names that have
I have a database table that looks like this: CREATE TABLE IF NOT EXISTS
I have a database that contains a table that looks a bit like this:
I have a table in a MSSQL database that looks like this: Timestamp (datetime)
I have a database with VARCHAR column url . I would like to fetch
I want to have a database table that keeps data with revision history (like
I have a database table like this: id version_id field1 field2 1 1 texta
I have a database with one table, like so: UserID (int), MovieID (int), Rating
I have a database table that i want to allow my friends to update.
I have a column TypeCode varchar(20) that has values like '1', '2', '3', 'FOO',

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.