I am defining VAT rates (European and other countries levy the VAT tax) in a SQL Server database and am wondering what the ideal decimal definition to capture the necessary precision.
I have seen VAT rates of:
20% (0.20) UK, Italy, Austria, etc.
21% (0.21) Belgium, Ireland, etc.
19.6% (0.196) Monaco, France
I am curious if there are cases where the VAT rate requires more precision than decimal(4, 3) where p is precision and s is scale. I have read a number of documents and am not sure if the EU or others have a particular specification for the VAT in terms of positions after the "." (or "," in their case). What's to stop the UK from saying their VAT is now 0.20111111 if they want to use some formula-based calculation for the VAT rate instead of a fixed-precision value?
Thanks in advance to you international men and women of mystery.
Precision is the number of digits in a number. Scale is the number of digits to the right of the decimal point in a number. For example, the number 123.45 has a precision of 5 and a scale of 2.
Please note: VAT rates should normally be entered as decimals. For example, 20% is the same as 0.20 and 5% is the same as 0.05.
Use the CAST() function to convert an integer to a DECIMAL data type. This function takes an expression or a column name as the argument, followed by the keyword AS and the new data type. In our example, we converted an integer (12) to a decimal value (12.00).
In standard SQL, the syntax DECIMAL( M ) is equivalent to DECIMAL( M ,0) . Similarly, the syntax DECIMAL is equivalent to DECIMAL( M ,0) , where the implementation is permitted to decide the value of M . MySQL supports both of these variant forms of DECIMAL syntax. The default value of M is 10.
According to the PDF document referred at the end of this page, you should be safe with decimal(4,3)
. Although it seems that some historical cases would have required a precision of 4.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With