mysql arithmetic with results of a subquery
Posted on 2009-07-08
I have a value that I can only get using a subquery. I can't seem to use that value in arithmetic. For example,
(select sum(cost) from miscexpenses where accountid = property.id) as costs,
works just fine, and
sellingprice - proceeds as closing_costs,
works fine too, but when I try to use the subquery result below in arithmetic, it bombs out say "costs" does not exist.
costs + closing_costs as total_cost