I have a SELECT along the lines of
SELECT
(very complex calc1) as `amount`,
(very complex calc2) as `paid_onlne`,
(very complex calc3) as `paid_by_check`,
(very complex calc1) - (very complex calc2)-(very complex calc3) as `amount_due`
FROM billings
GROUP BY billings.id
All the calculations use one-many sub_selects
This has been asked before, but I am looking for a way to be able reuse the calc specifications 1,2,3 in subsequent columns without having to paste the code over and over - leaving a query that is very difficult to maintain.