The reply selected as the best answer in this thread was helpful. But, it seems “ORDER BY FIELD” is not supported in SQLite.
Using this example, how can I set a specific order to the rows in the Month column?
The reply selected as the best answer in this thread was helpful. But, it seems “ORDER BY FIELD” is not supported in SQLite.
Using this example, how can I set a specific order to the rows in the Month column?
There is no ORDER BY FIELD
in SQLite.
Instead you can do it with conditional ordering:
ORDER BY CASE month
WHEN 'JAN' THEN 1
WHEN 'FEB' THEN 2
WHEN 'MAR' THEN 3
WHEN 'APR' THEN 4
WHEN 'MAY' THEN 5
WHEN 'JUN' THEN 6
END
or by using INSTR()
:
ORDER BY INSTR('JAN,FEB,MAR,APR,MAY,JUN', month)
you can omit the commas or replace with any other separator.