Skip to content

Instantly share code, notes, and snippets.

@neurotech
Created August 18, 2015 11:32
Show Gist options
  • Save neurotech/8386fb10ac04097f9fa6 to your computer and use it in GitHub Desktop.
Save neurotech/8386fb10ac04097f9fa6 to your computer and use it in GitHub Desktop.
COALESCE-ing first names and preferred names
SELECT
COALESCE(contact.preferred_name, contact.firstname) AS "FIRSTNAME",
contact.surname
FROM contact
ORDER BY contact.surname, contact.preferred_name, contact.firstname
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment