Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Use Result Set Column Names in same SELECT?

Status
Not open for further replies.

Natha2

Programmer
Dec 23, 2004
17
0
0
BE
Hi,
Following statement returns an error:

SELECT
AMOUNT_A + AMOUNT_B + AMOUNT_C [+ ...n] AS AMOUNT_TOT,
AMOUNT_TOT*1.21

How can I overcome this problem?
I need to do this for far more complex calculations, so it is quite critical not to do it as follows:

SELECT
AMOUNT_A + AMOUNT_B + AMOUNT_C AS AMOUNT_TOT,
(AMOUNT_A + AMOUNT_B + AMOUNT_C) *1.21

Thanx in advance for any tip!
Natha
 
Code:
select AMOUNT_TOT
     , AMOUNT_TOT * 1.21
  from (
       select AMOUNT_A 
            + AMOUNT_B 
            + AMOUNT_C 
            + ...       as AMOUNT_TOT
         from daTable
       ) as d

r937.com | rudy.ca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top