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 ..
There’s more than one way to skin a cat, this is one of them.
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.