Skip to content Skip to sidebar Skip to footer

Coalesce And Concat In The Same Statement, Postgres

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 do

Solution 1:

Just use the concatenation operator, ||:

coalesce(first_name || ' ' || last_name, team_name)

The concat() function ignores NULL values. The operator returns NULL.

Post a Comment for "Coalesce And Concat In The Same Statement, Postgres"