I am trying to concat an individual's first and last name together but coalesce a team name when there is a null value. Unfortunately my syntax is returning a SPACE, so coalesce does not recognize it as a null value.. What can I do to correct this?
Syntax I am currently using:
coalesce((Concat(first_name,' ',last_name)),team_name)
Just use the concatenation operator, ||:
coalesce(first_name || ' ' || last_name, team_name)
The concat() function ignores NULL values. The operator returns NULL.
来源:https://stackoverflow.com/questions/41770098/coalesce-and-concat-in-the-same-statement-postgres