Margin Calculations

I'm asked from time to time to do margin calculations, especially in reporting. 

After looking this up 3 times a year for forever (smiles) I'm just going to create a post so I'll have it. 

The value of this article is in the menu structure (above). Follow the link that says 'This article, and all our great SQL (General) documentation'... and remember where it is for when you need it. 

--margin calculations
 
DECLARE @cost Numeric(19,5) = '100'
DECLARE @price Numeric(19,5) = '142.86'
 
--formula to get the actual margin from cost and price
SELECT actualmargin = (@price - @cost) / @price
 
DECLARE @intendedMargin Numeric(19,5) = .30
 
--formula to get the price from the cost and intended margin
SELECT price = @cost / (1 - @intendedMargin)

RealWorldCode gives developers practical, real‑world solutions with clean, working code — no fluff, no theory, just answers.
Links
Home
Knowledge Areas
Sitemap
Contact
Et cetera
Privacy Policy
Terms and Conditions
Cookie Preferences