I'm not sure if this is the issue, but a sub-select referencing an aliased table doesn't seem to work:
acspg3=> select count(*) from ec_orders o
acspg3-> where o.order_id = (select max(order_id) from ec_orders);
count
-------
1
(1 row)
acspg3=> select count(*) from ec_orders o
acspg3-> where o.order_id = (select max(order_id) from o);
ERROR: Relation 'o' does not exist