Subject ORDER BY invalid column
Author Rick Debay
I was running a one-off query in order to do some inventory analysis,
and got this error. FB will only allow me to choose columns returned
from the table in this query, not generated columns (ORDER BY 9 also
fails). Which is strange, as I know I've used generated columns in
other queries.

Dynamic SQL Error SQL error code = -104 Invalid column position used in
the ORDER BY clause

select
p.*,
(p.decimalqty - p.order_qty - p.po_qty - p.bo_qty) outstanding,
(select first 1 d.labelname from mddb_drug d where d.PRODUCTID/100 =
p.ndc9) <== column 10
from
P_RPL_NDC9_2( '01J' ) p
where
(p.decimalqty - p.order_qty - p.po_qty - p.bo_qty) > 0
order by
10