Skip to content

Instantly share code, notes, and snippets.

@imsarvesh
Created March 16, 2018 13:10
Show Gist options
  • Save imsarvesh/0c72f29ab5d521d311e834cd75851add to your computer and use it in GitHub Desktop.
Save imsarvesh/0c72f29ab5d521d311e834cd75851add to your computer and use it in GitHub Desktop.
SELECT
CASE
WHEN u.first_name IS NULL AND u.last_name IS NULL THEN u.username
WHEN u.first_name = '' AND u.last_name = '' THEN u.username
ELSE u.first_name || ' ' || u.last_name
END as "name"
FROM users
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment