Table of Contents

Search

  1. About the Data Vault SQL Reference
  2. Introduction to SQL Reference for Informatica Data Vault
  3. Date and Time Arithmetic
  4. WHERE Clauses
  5. UNION Operator
  6. Parameterized Query
  7. Functions

Data Vault SQL Reference

Data Vault SQL Reference

COALESCE

COALESCE

Returns the first argument that is not null. The arguments are evaluated in the order in which they are specified. The result is null only if all the arguments are null.

COALESCE Example

SELECT lastname, job_desc, COALESCE(salary, contract, commission, subsistence) FROM payroll;
In this example, a worker on the payroll is paid either a regular salary, contract pay, a commission, or subsistence wages. The COALESCE function returns the value for the appropriate pay type, assuming all but the applicable pay field store null values. If none of the pay types apply, a null value is returned.
The equivalent (searched) CASE expression for this example would be the following:
SELECT lastname, job_desc, CASE WHEN salary IS NOT NULL THEN salary WHEN contract IS NOT NULL THEN contract WHEN commission IS NOT NULL THEN commission WHEN subsistence IS NOT NULL THEN subsistence ELSE NULL END FROM payroll;

0 COMMENTS

We’d like to hear from you!