user defined function for calculating cost * products

Posted by Parthibansk under Sql Server on 8/14/2012 | Points: 10 | Views : 779 | Status : [Member] | Replies : 2
i want 2 calculate products price.. by input cost * no of units and display in textbox




Responses

Posted by: San.Pblr.Gct on: 8/14/2012 [Member] Starter | Points: 25

Up
0
Down
Why do you want user defined function?ANy specific reasons?

If you have both the columns in same table, then
Select UnitPrice,NoOfProducts,(UnitPrice*NoOfProducts) as TotalPrice from tbl_Temp

Parthibansk, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Muhsinathk on: 9/4/2012 [Member] Bronze | Points: 25

Up
0
Down
Hi
Please execute this query
1) If UnitPrice and NoOfProducts are in same table
Select UnitPrice,NoOfProducts,(UnitPrice*NoOfProducts) as TotalPrice from table_name
2) If UnitPrice and NoOfProducts are in different table
Select T1.UnitPrice,T2.NoOfProducts,(T1.UnitPrice*T2.NoOfProducts) as TotalPrice from table1 T1 join Table2 T2 on T1.ID=T2.ID

Parthibansk, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response