I've got a table containing a mixture of left and right shoes, some of which are waterproof.
I need to write a query to sort them alphabetically, but- when the name is the same- use the waterproof column ahead of left/right.
e.g.
+-------------------------+------------+------------+
| Shoe name | Waterproof | Left/Right |
+-------------------------+------------+------------+
| boot | 0 | left |
| sandal | 0 | left |
| shoe | 1 | left |
| boot | 1 | left |
| boot | 0 | right |
| boot | 1 | right |
| sandal | 0 | right |
| shoe | 1 | right |
+-------------------------+------------+------------+
Should be sorted as such...
+-------------------------+------------+------------+
| Shoe name | Waterproof | Left/Right |
+-------------------------+------------+------------+
| boot | 0 | left |
| boot | 0 | right |
| boot | 1 | left |
| boot | 1 | right |
| sandal | 0 | left |
| sandal | 0 | right |
| shoe | 1 | left |
| shoe | 1 | right |
+-------------------------+------------+------------+
Can it be done?
On your modified data structure, the following should work:
You can try:
OR by column name: