Can I base calculations on other calculations within my Select statement, or do I need to base each calculation on the underlying components?
For example, I have this query
I would like to add one more calculated field to the Select statement, to determine the difference between the Elections and Deposits calculations, i.e.
but that doesn’t appear to work.
Do I have to do it like:
or is there a shorter way?
For example, I have this query
Code:
SELECT
A.SOCIAL_SECURITY_NUM,
(A.TOTAL_ELECTIONS + A. TOTALOTHERADHOC + A.TOTAL_ROLLOVER) AS ELECTIONS,
(A.SUMOFANNUAL_EMPLOYEE_PRETAX_CONTRIB + A.SUMOFANNUAL_EMPLOYER_PRETAX_CONTRIB) AS DEPOSITS
FROM
QRY_MEMBER125_BENEFITS_STATUS AS A
I would like to add one more calculated field to the Select statement, to determine the difference between the Elections and Deposits calculations, i.e.
Code:
(ELECTIONS – DEPOSITS) AS DIFFERENCE
Do I have to do it like:
Code:
(A.TOTAL_ELECTIONS + A. TOTALOTHERADHOC + A.TOTAL_ROLLOVER - A.SUMOFANNUAL_EMPLOYEE_PRETAX_CONTRIB - A.SUMOFANNUAL_EMPLOYER_PRETAX_CONTRIB) AS DIFFERENCE