I missed this when sorting users the first time. Users with no full
name entered would show up as blank.
I also wanted to make sure that all the users that only had emails
didn't show up clumped up at the bottom or top. We ensure that users
always have some value in the full_name column, even if it's an empty
string. Postgres sorts empty strings to the top making all the no-name
users show up there. Here's the SQL:
SELECT*FROMusersORDERBYCOALESCE(NULLIF(full_name,''),email);First, empty strings are treated as null (NULLIF). Then, if there is
no full_name, we use email (COALESCE).