Reputation: 1
I am not sure whether its asked previously but I can't find it while searching.
My query is while executing my sql statement it will return some number -- for instance 5
-- but I want to display it as 1
.
How to do this? Can someone suggest? Also I want to compare null
from database and replace it will 0
. I used NVL
, ISNULL
, Colesace
but none of them are working. I am using MySQL server.
Can someone please help?
-Kshan
Upvotes: 0
Views: 35
Reputation: 48169
If you are looking for any non-zero/null, you might try
select ( case when number is null or number is 0 then 0 else 1 end ) Flag1or0
Or at least that is what it APPEARS you are looking for...
Upvotes: 1
Reputation: 1270573
You want to use a case
expression:
select (case when number = 5 then 1 else number end) -- or whatever your logic is
For the special case of NULL
, the logic is:
select coalesce(number, 0)
Upvotes: 0