Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Formulated Columns

Author  Topic 

osirisa
Constraint Violating Yak Guru

289 Posts

Posted - 2012-01-18 : 15:11:15
I have two calculated columns. I have to create a third calculated column using the values of these two previous calculated columns. But, it doesn't matter how I write the function statement is invalid when I try to enter the calculation portion in the Column property.
Select Sales_Dollars*Actual_SVM_percent - Expected_SVM
from SHP_Project
------------------------------------------------
Does anyone knows if I can use two calculated columns to create a third calculated column?

Thanks,

ehorn
Master Smack Fu Yak Hacker

1632 Posts

Posted - 2012-01-18 : 15:28:11
Perhaps you could place your results within a derived table and then perform the calculations? Something like:


SELECT <your last calculation>
FROM
(
--Your query here
) d


HTH.
Go to Top of Page

osirisa
Constraint Violating Yak Guru

289 Posts

Posted - 2012-01-18 : 15:31:12
Are you suggesting placing the results in a Temp Table? How do I keep update the results and update the new column
Go to Top of Page

ehorn
Master Smack Fu Yak Hacker

1632 Posts

Posted - 2012-01-18 : 15:34:16
quote:
Originally posted by osirisa

Are you suggesting placing the results in a Temp Table? How do I keep update the results and update the new column



I am suggesting you consider a derived table... This is a type of query which allows you to treat what is 'inside the parenthesis' as a base table and perform functions on it as if it were a temp table.

You can search for 'derived table' for insights into their syntax and behavior.

HTH.
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2012-01-18 : 16:09:58
I suggest you create a VIEW



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page
   

- Advertisement -