Mainframe: DB2 NULLIF Scalar Function

NULLIF returns a null value if the two arguments of the function are equal. If the arguments are not equal, NULLIF returns the value of the first argument.

DB2+Mainframe+CICS+Updated+JOBS

[If your from INDIA please search here ]

Example:NULLIF: Suppose that you want to calculate the average earnings of all employees who are eligible to receive a commission. All eligible employees have a commission of greater than 0, and ineligible employees have a value of 0 for commission:SELECT AVG(SALARY+NULLIF(COMM,0))
AS “AVERAGE EARNINGS”
FROM EMP;The result table looks like this:

AVERAGE EARNINGS
================
35248.8461538

Ref: IBM

Advertisements