SQLite Forum

ORDER BY out of order. Is this a bug or expected?
Login
I believe order by is supposed to look at the column aliases first, yes. I can't point you to anything specific that says it though.

Don't forget you can order by something that's not in the result columns. So you can explicitly say the column you want to order by.

```
sqlite> select printf('%8.2f', n) as n from t order by t.n desc;
┌──────────┐
│    n     │
├──────────┤
│   500.00 │
│  -574.41 │
└──────────┘

sqlite>```