EasyString Functions

Concatenate first and last name with CONCAT_WS

The query

SQL
SELECT
  CONCAT_WS(' ', first_name, last_name) AS full_name,
  CONCAT_WS('@', LOWER(first_name), 'company.com') AS suggested_email,
  UPPER(LEFT(first_name, 1)) || LOWER(last_name) AS username
FROM employees;
Tested against PostgreSQL 16

Note

CONCAT_WS skips NULL arguments. LEFT(str, n) takes first n characters. Useful for username generation.

Tables referenced