I have a table which I’m trying to arrange by 2 fields, one of which I want to alter by case.
SELECT * FROM products WHERE disabled=’0′ ORDER BY category, status
That works fine, until status has certain values. status comes directly from xml, and we can’t really change it. We don’t know what the value is. All we know is that there are 3 certain terms which we need in certain order, then the rest ordered ascending by status.
when status='1' we want it to be 1st;
when status='D' we want it to be 2nd
when status='2' we want it to be 3rd
then the rest order by status because they carry different values..
sample output:
category | status
electronic | 1
electronic | D
electronic | 2
electronic | 9
misc | 1
misc | 2
misc | 8
Try this: