Is it possible to use case
expression in order-by
?
#414
Labels
documentation
I need to write something up!
case
expression in order-by
?
#414
I would like to be able to sort by different fields based on a condition. This is supported at least in Postgresql.
I tried to express this in HoneySQL V2:
..which yields weird results
=> ["SELECT * FROM my_table ORDER BY case ASC, = FIELD_X, field_y ASC, else ASC, field_z ASC"]
From the docs I can read that
:order-by
accepts a sequence of one or more ordering expressions. but apparently I want to use a "normal expression" instead of an "ordering expression" in this case.Is there a workaround how this can be achieved without falling back to raw SQL?
The text was updated successfully, but these errors were encountered: