if else in Oracle SQL

idmdeveloper
idmdeveloper used Ask the Experts™
on
Hi;

I have a query need to select column from a table:

If columne value = 0, show empty
otherwise, just show what its original value.

How can i accomplish it?

Thanks in advance
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2009
Commented:
Use decode or case. I assume you meant null rather than 'empty', otherwise if you want 'empty' replace null below with the string 'empty'

select decode(col, 0, null, col) from tab;

select case col when 0 then null else col end from tab;
awking00Information Technology Specialist
Commented:
You can also use nullif(col,0)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial