I have a sort problem in PostgreSQL with below data:
name
-----
@CF
@CG
CD
CE
I used select name from table order by name, the
Your undisclosed collation setting obviously ignores the @ character for sort order. Either switch to another collation as suggested by @Craig. Or, if you want to stick to your collation for the rest of the string, add a special case for leading @.
In Postgres you can order by boolean values directly. Default order is FALSE, TRUE, NULL.
ORDER BY name !~~ '@%', name
!~~ being the Postgres shorthand for NOT LIKE.