Hi all suppose i have the following table
CREATE TABLE #ResultTable (NettAmount money, GrossAmount money,TotalVat money)
Given a gross amount eg=250 I know that vat is at 17.5% How Do i calculate the totalVat?
Thanks for any suggestions
Hi all suppose i have the following table
CREATE TABLE #ResultTable (NettAmount money, GrossAmount money,TotalVat money)
Given a gross amount eg=250 I know that vat is at 17.5% How Do i calculate the totalVat?
Thanks for any suggestions
INSERT #ResultTable
(NettAmount, GrossAmount, TotalVat)
SELECT
NettAmount, GrossAmount, GrossAmount * 17.5 /100
FROM
SourceTable
It's unclear what you want to do, sorry...
devnet247 - have a 2nd table that contains the valid date tracked VAT rate along the lines of:
vat_rate | vat_type | stt_date | end_date
-----------------------------------------
0.175 | 1 | 20100101 | null
vat_type | description
-----------------------------------------
1 | standard rate
2 | reduced rate
3 | zero rate
and then join on that table where the invoice date is valid for the row. your final sql would be along the lines of
SELECT SUM(NettAmount * vat_rate as total_vat) from #ResultTable r1, vat_table v1
where r1.invoice_date between v1.stt_date and v1.end_date
and r1.vat_type = v1.vat_type
anyway, if you were tracking the vat that is :)
jim
[edit] - if you were to use a second table, i'd suggest extending that to a 3rd - vat_type table, as vat rates vary across products as well as time. see http://www.hmrc.gov.uk/vat/forms-rates/rates/rates.htm#1
SELECT SUM(GrossAmount) * 17.5 /117.5 AS VATAmount
FROM SourceTable
Bearing in mind that (UK) VAT is due to increase to 20% from January 2011, it would be a good idea to follow Jim's suggestion of a date-tracked VAT rate lookup table.