I've run across a bug with order by:
select 1 as a order by a;
-- works
select 1 as a, 2 as b order by a;
-- works
select 1 as a, 2 as b order by a + b;
ERROR: column "a" does not exist
select * from (select 1 as a, 2 as b) stuff order by a + b;
-- works