Last active
May 11, 2016 18:08
-
-
Save alex-oliveira/1c34737439afbd18cd5540ffa946431c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT * FROM (VALUES (0, 'desativado'), (1, 'ativado')) AS z(id, status); | |
------------------------------------ | |
SELECT u.id, u.nome, u.ativo, z.status | |
FROM autenticacao.usuarios as u | |
INNER JOIN (VALUES (0, 'desativado'), (1, 'ativado')) AS z(id, status) ON z.id = u.ativo | |
ORDER BY z.status ASC; | |
------------------------------------ | |
SELECT u.id, u.nome, u.ativo, z.status | |
FROM autenticacao.usuarios as u | |
INNER JOIN (SELECT unnest('{0, 1}'::int[]) as id, unnest('{"desativado", "ativado"}'::varchar[]) as status) z ON z.id = u.ativo | |
ORDER BY z.status ASC; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment