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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calculating fields in a view

Status
Not open for further replies.

mikeEd

Programmer
Joined
Nov 26, 2001
Messages
160
Location
GB
I have a view that is something like the following:
Code:
SELECT
	(Field1 * 10) AS CalcField1,
	(Field1 * 10) + Field2 AS CalcField2,
	(Field1 * 10) + Field2 - 2 AS CalcField3
FROM
	TABLE
i.e. Subsequent fields are calculated based on the value of earlier calculated fields.
Is there any obvious way to do...
Code:
SELECT
	(Field1 * 10) AS CalcField1,
	CalcField1 + Field2 AS CalcField2,
	CalcField2 - 2 AS CalcField3
FROM
	TABLE
Thanks.
 
The way you have it written in the first version is the only way I know of to do something like that. I know I have often wished when I had a significant calculation to do and then needed the result for another one I wished I coud just use the field name but alas...... Crystal
crystalized_s@yahoo.com

--------------------------------------------------

Experience is one thing you can't get for nothing.

-Oscar Wilde

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top