If a row in the column is undefined, we say that it is NULL. This is not the same as the value 0
An expression in which it will occur will also be NULL. Therefore, the expression SAL*12+COMM will return NULL where COMM NULL.
SELECT ENAME, SAL*12+COMM
FROM EMP;
To treat the expression as NULL, use the NVL function.
SELECT ENAME, SAL*12+NVL(COMM,0) YEAR_SAL
FROM EMP;
In this example, NULL values will hold their value and the value of NULL is treated as the 0
The second parameter specifies the NVL function for which the value is converted to NULL:
NVL (DATE,'85/09/01')
NVL (NUMBER,10)
NVL (CITY,'New Yotk')
No comments:
Post a Comment