This HAS to be a PEBCAK problem as it seems so basic. Is there a query to say, "If 'mon' = 1 THEN ORDER BY 'time' THEN if 'tue' = 1 ORDER BY 'time', THEN if 'wed' = 1 ORDER BY 'time'" ?
===== ===== ===== ========
| mon | tue | wed | time |
===== ===== ===== ========
| 0 | 1 | 1 | 0100 |
| 0 | 0 | 0 | 2200 |
| 1 | 1 | 1 | 1500 |
| 1 | 1 | 0 | 0600 |
| 0 | 0 | 0 | 1400 |
| 1 | 0 | 1 | 1100 |
===== ===== ===== ========
Desired result:
mon 0600
mon 1100
mon 1500
tue 0100
tue 0600
tue 1500
wed 0100
wed 1100
wed 1500
CodePudding user response:
...
ORDER BY CASE WHEN mon=1 THEN 1 WHEN tue=1 THEN 2 WHEN wed=1 THEN 3 END,
time