NVL function:
The NVL function is a null conversion function, which converts a null value (NULL) into an actual value. The format is as follows:
NVL(expression one, expression two);
If expression one is null, NVL returns the value of expression two; otherwise, it returns the value of expression one;
The expression can be numeric, character, or date; however, the data types of expression 1 and expression 2 must be the same;
Digital: NVL(comm,0);
字符型 : NVL (tochar (comm), 'No Commission');
Date type: NVL('hiredate','31-DEC-99');
DECODE function
Since there is no logical judgment statement (branch statement) in SQL, the decode function accomplishes similar functions;
Example: Find the salary value of each employee after a salary increase in different positions (job)
select ename "name" , job , sal "salary" , DECODE(job,'SALESMAN',sal*1.15,'CLERK' , sal*1.2,'ANALYST',sal*1.25,sal*1.40) "New Salary" from emp order by job;