Mysql
 sql >> Base de Dados >  >> RDS >> Mysql

Simulando ORDER BY FIELD() do MySQL no Postgresql


Ah, gahooa estava tão perto:
SELECT * FROM currency_codes
  ORDER BY
  CASE
    WHEN code='USD' THEN 1
    WHEN code='CAD' THEN 2
    WHEN code='AUD' THEN 3
    WHEN code='BBD' THEN 4
    WHEN code='EUR' THEN 5
    WHEN code='GBP' THEN 6
    ELSE 7
  END,name;