Search code examples
sqlsql-servert-sqlsql-server-2014

How to find amount exclusive of tax from an amount inclusive of tax?


How to find amount exclusive of tax from an amount inclusive of tax? Currently I'm using this query and getting the desired result. I am searching for a simple query.

My current query:

select @amountExclusiveOfTax=
    (@amountInclusiveOfTax) - 
    ((@amountInclusiveOfTax) - (((@amountInclusiveOfTax)/@taxPercent+100) * 100))

Is there any easier way?


Solution

  • This was taught in day one of my business math class:

    SELECT @amountExclusiveOfTax = @amountInclusiveOfTax / (1 + @taxPercetange / 100)
    

    This assume your @taxPercentage is stored in percentage form. For example, if the tax is 15%, then @taxPercentage = 15. Another popular form is the decimal form, where it's stored as 0.15.