3
I believe using order by with a CASE
solve your problem:
ORDER BY
CASE ColunaValor WHEN 'DIAMANTE' THEN 0
WHEN 'OURO' THEN 1
WHEN 'PRATA' THEN 2
WHEN 'BRONZE' THEN 3
END
3
2
I believe using order by with a CASE
solve your problem:
ORDER BY
CASE ColunaValor WHEN 'DIAMANTE' THEN 0
WHEN 'OURO' THEN 1
WHEN 'PRATA' THEN 2
WHEN 'BRONZE' THEN 3
END
1
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
Browser other questions tagged sql sql-server query
You are not signed in. Login or sign up in order to post.
place the structure of your tables and the code you are using, avoid putting the print of your screen.
– Rovann Linhalis
I imagine that the "Description" should be in another table doing Join in your select, if this is the case, put a property to sort in that other table to avoid hard-code in the query
– Rovann Linhalis