TDengine
TDengine copied to clipboard
ORDER BY specific values in columns
Is it possible to support ORDER BY specific values in columns, like what is described in the following SQL snippet from StackOverflow.
...
WHERE
x_field IN ('f', 'p', 'i', 'a') ...
ORDER BY
CASE x_field
WHEN 'f' THEN 1
WHEN 'p' THEN 2
WHEN 'i' THEN 3
WHEN 'a' THEN 4
ELSE 5 -- fallback for values not inside the IN clause. eg : x_field = 'b'
END, id
Additional context https://stackoverflow.com/questions/6332043/sql-order-by-multiple-values-in-specific-order
we will check on this