09.02.2024 NVL Coalesce Notepad
09.02.2024 NVL Coalesce Notepad
09.02.2024 NVL Coalesce Notepad
NULL:-
UNKNOW VALUE
UNDEFINED VALUE
ITS ABSENCE OF DATA
SELECT dbms_metadata.get_ddl('TABLE','EMP')
FROM DUAL;
IT IS TWO TYPE
1. SINGLE ROW FUNCTION
2. MULTIROW FUNCTION/AGGREGATE FUNCTION
COLUMN OR EXPRESSION
SELECT NVL(NULL,100) FROM DUAL;
SELECT NVL('SCOTT',100) FROM DUAL;
SELECT NVL(200,100) FROM DUAL;
SELECT NVL(100,100) FROM DUAL;
SELECT NVL(100) FROM DUAL;--ORA-00909: invalid number of arguments
NVL2:-
NULLIF:-
1. NULLIF USED TO COMPARE BETWEEN PARAMETERS IF MATECHS THEN DISPLAY NULL
IF DOESNT MATCH THEN DISPLAY FIRST PARAMETER VALUE
2. IT ACCEPTS TWO PARAMETER
3. IT IS A SINGLE ROW FUNCTION
4.DATA TYPE SHOULD MATCH BETWEEN THE PARAMETERS
COALESCE:-
1.COALESCE FUNCTION IS USED TO PROVIDE FIRST NOT NULL VALUE AMONG THE PARAMETERS
2.WE CAN TAKE N NUMBER OF PARAMETERS
3.DATA TYPE SHOULD MATCH BETWEEN THE PARAMETERS
4.IT IS A SINGLE ROW FUNCTION
ALIAS NAME:-
ALIAS :-
1. ALIAS IS AN ALTERNATE NAME GIVEN FOR A COLUMN OR TABLE
2. ALIAS RENAME FOR TEMPORARY PURPOSE
TABLE ALIAS:-
SELECT EMPNO ,ENAME , JOB, ENAME || ' --> ' || JOB AS EMPLOYEEJOB FROM EMP;
SELECT ENAME ||' IS EARNING MONTHLY SALARY :- ' || SAL FROM EMP;
ENAME, SALARY
KING'S COMM IS 0
ALLEN'S COMM IS 300
SELECT ENAME || '''S COMM IS ' || NVL(COMM,0) FROM EMP WHERE ENAME ='KING';