Repeating formulas in a query
Consider the following query:
SELECT SUM( ... ), SUM( ... ), SomeSolumn
My problem is that the SUMs are based on large formulas, and SomeColumn should display the difference between the two. However, I don't want to repeat both formulas. So my approach was:
SELECT SUM( ... ) as S1, SUM( ... ) as S2, (S2 - S1)
But it doesn't seem to work. Any ideas?