COALESCE
Returns the value of the first non-null expression in the list. If all expressions evaluate to null, then COALESCE
returns null.
COALESCE
conforms to the ANSI SQL-92 standard.
Behavior Type
Syntax
COALESCE ( expression[,…] );
Example
=> SELECT product_description, COALESCE( lowest_competitor_price, highest_competitor_price, average_competitor_price) AS price FROM product_dimension LIMIT 10; product_description | price -----------------------------+------- Brand #313 corn muffins | 565 Brand #591 hot dogs | 323 Brand #1247 american cheese | 263 Brand #1510 whole milk | 183 Brand #2549 vegatable soup | 491 Brand #4520 catfish | 113 Brand #4684 onions | 56 Brand #6078 salmon | 195 Brand #6924 bananas | 80 Brand #7912 green peppers | 180 (10 rows)