Link to home
Start Free TrialLog in
Avatar of TechMonster

asked on

Returning values depending on data in column

I have a query in oracle..looking at returning a numeric value of 1 if a column is not NULL and 0.
some folks said that it would be similar to SQL but my query doesn't work.

So the value I want to change is Col2.  Set to 1 if the there is anything in Col2, and 0 if it is NULL.

If Col2 is NOT NULL THEN 1
Else 0 NewColName,
From Database.
Avatar of slightwv (䄆 Netminder)
slightwv (䄆 Netminder)

Select col1, case when col2 is not null then 1 else 0 end mycol from table;
Select col1, decode(col2,null,0,1) mycol from table;
Decode is still valid but is being phased out.
Avatar of Sean Stuber
Sean Stuber

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of TechMonster


This is the solution I used...thanks
why the B?  that's a penalty grade,  what more did you want for an A?