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
 Use value of one column into another in function

Author  Topic 

MonikaAhujaRBS
Starting Member

9 Posts

Posted - 2014-06-23 : 02:30:09
Hi,

I'm facing an issue in a function.

I have a function say func()

create function func()
(

select p1 as Price , m1 as Market, [Price]*[Market] from tableP1, tableM1

}


Now i want to add one column into it whose value is multiple of Price*Market. How can i achieve this. function is not allowing me to do this. I don't want to calculate Price and market again for the third column as while calculating it requires many Case statements.

Could someone please help me with this?

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2014-06-23 : 02:37:25
You can use either a derived table or a CTE.


Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA
Go to Top of Page

MonikaAhujaRBS
Starting Member

9 Posts

Posted - 2014-06-23 : 03:36:28
Thanks Patron. Patron could you please give me a sample code to do the same?
Go to Top of Page
   

- Advertisement -