TDengine icon indicating copy to clipboard operation
TDengine copied to clipboard

ORDER BY specific values in columns

Open HtwoO opened this issue 1 year ago • 1 comments

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

HtwoO avatar Jun 18 '24 07:06 HtwoO

we will check on this

yu285 avatar Jun 25 '24 01:06 yu285