Last answered:

15 Dec 2021

Posted on:

02 Nov 2021

1

COALESCE('placeholder') vs. 'placeholder'

What's the difference between using COALESCE() function instead of just using the literal by itself to output placeholders?

# This simpler one:
SELECT dept_no, dept_name, 'department manager name' AS fake_col FROM departments_dup;
# over COALESCE:
SELECT dept_no, dept_name, COALESCE('department manager name') AS fake_col FROM departments_dup;
1 answers ( 0 marked as helpful)
Instructor
Posted on:

15 Dec 2021

0

Hi Duncan!
Thanks for reaching out.

In this particular case there is no difference.
The COALESCE() function returns the first non-null value in a list. It is usually used with columns and checking if the current column is NULL.

Hope this helps.
Best,
Tsvetelin

Submit an answer