Good afternoon!
Well, I have the following query below, however, I want to sort by specifying some records. Attached for example, is the generated query and I want the Value column to look like this: Diamond Gold Bronze Silver
You can create an order column with CASE
:
SELECT CASE t.campo
WHEN 'DIAMANTE' THEN 0
WHEN 'OURO' THEN 1
WHEN 'PRATA' THEN 2
WHEN 'BRONZE' THEN 3
END AS ordem
FROM tabela t
ORDER BY 1
I believe that using order by with CASE
solves your problem:
ORDER BY
CASE ColunaValor WHEN 'DIAMANTE' THEN 0
WHEN 'OURO' THEN 1
WHEN 'PRATA' THEN 2
WHEN 'BRONZE' THEN 3
END