given
create table foo (a int, b int);
insert into foo values (1,1),(1,2),(2,1),(2,2),(2,3);
I want to order first by a=1 DESC and second by b, ASC if a=1 and DESC if a<>1.
for example,
select a,b from foo order by a=1 DESC, b ASC;
produces
| a | b |
|---|---|
| 1 | 1 |
| 1 | 2 |
| 2 | 1 |
| 2 | 2 |
| 2 | 3 |
but I'm trying for
| a | b |
|---|---|
| 1 | 1 |
| 1 | 2 |
| 2 | 3 |
| 2 | 2 |
| 2 | 1 |