Problem solve Get help with specific problems with your technologies, process and projects.

Replace NULL values

Convert NULL values to whatever you want with this simple command.

By using this script, you can display what you want in place of null values. This is Oracle-specific syntax.

SQL > set null 
  

 

That's it! Here's an example:

SQL> SET NULL X 
SQL> SELECT ENAME,COMM FROM EMP; 

The result of this would be:

RESULT :- 
ENAME   COMM 
-----  ------ 
SCOTT    X 
KING    200 
AKRAM   500 
SMITH    X 

Reader Feedback

Lynn H. writes: Wouldn't it be easier to do the following:

SELECT ENAME, DECODE(COMM,'',COMM) AS COMM FROM EMP

The result of this would be:

RESULT :- 
ENAME   COMM 
-----  ------ 
SCOTT    X 
KING    200 
AKRAM   500 
SMITH    X 

Ravi G. writes: The following SQL statement will also do the same thing:

SQL> SELECT ENAME, NVL(COMM, 'X') COMM FROM EMP;

The result of this would be:

 
 RESULT :- 
 ENAME   COMM 
 -----  ------ 
 SCOTT    X 
 KING    200 
 AKRAM   500 
 SMITH    X 

For More Information


Dig Deeper on Oracle and SQL

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchDataManagement

SearchBusinessAnalytics

SearchSAP

SearchSQLServer

TheServerSide.com

SearchDataCenter

SearchContentManagement

SearchHRSoftware

Close