I am constructing a query that pulls values out according to a set of ORDER BY instructions
SELECT * from values ORDER BY displayOrder, actualValue, field(key, 'A', 'B', 'C')
So this may return:
name productType displayOrder actualValue key
object_a X 1 1.2 A
object_b Z 1 1.2 C
object_c Z 1 1.6 B
object_d X 1 1.8 B
However, if productType = Z, I want to switch around the ORDER BY actualValue and field(key) to produce the following:
name productType displayOrder actualValue key
object_a X 1 1.2 A
object_c Z 1 1.6 B
object_b Z 1 1.2 C
object_d X 1 1.8 B
Is this possible in any way?
Try this:
The idea is to put your
order byexpressions in both orders, but use only one of them for each row.