.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
Easy Web
Imran Ghani

Home >> Forum >> ADO.Net >> Post New QuestionBookmark and Share Subscribe to Forum

How to calculate profit using sqlserver ?

Posted By: pranay     Posted Date: March 06, 2011    Points:5   Category :ADO.Net
I have two tables.
1)product
2)sales

product table member
productno (primarykey) ,productname , costprice, salesno(foreigne key)

sales table member
salesno(primary key), sellingprice , profit

I wanted calculate profit using costprice in product table and sellingprice of sales table.

please send code for this and

stored procedure.

Responses
Author: Senthilnathan          Accepted Answer   
Posted Date: March 06, 2011     Points: 40   

check with this,

update Sales set profit=sellingprice-(select b.costprice from Prod b where b.salesno=salesno)

Author: Maverick             
Posted Date: March 07, 2011     Points: 20   

Hello,

Please create the tables properly first you are having no reference of product in your sales table you can use the query like.

Select (a.sellingprice-b.costprice) as profit from product b inner join sales a on a.productid=b.productid

Hope it helps.

Thanks,
Maverick

Thanks,
Maverick
Author: pranay             
Posted Date: March 07, 2011     Points: 20   

thank you...problem solved.



Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend