Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

For VAT tax, what is the correct Decimal(p, s) precision and scale for SQL Server field size declaration?

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.

like image 835
Mark A Avatar asked Mar 31 '11 06:03

Mark A


People also ask

What is scale and precision in decimal?

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.

Can VAT be a decimal?

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.

How do I select decimal value in SQL?

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).

What is the data type for decimal in SQL?

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.


1 Answers

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.

like image 131
Tommi Avatar answered Nov 15 '22 05:11

Tommi