Results 1 to 2 of 2
Thread: SQL Question - Column Datatype
Mar 22, 2010, 02:01 #1
- Join Date
- Apr 2005
- 0 Post(s)
- 0 Thread(s)
SQL Question - Column Datatype
I've tried an integer column and a decimal column but whenever I try to input the figure '11.50' it automatically changes it to '12'.
I'm also using the SUM() function on these columns so using varchar or something similar isn't an option.
I cant see why my figure changes within an integer or decimal column.
Mar 22, 2010, 02:15 #2
- Join Date
- Aug 2008
- The Netherlands
- 136 Post(s)
- 2 Thread(s)
From the MySQL manual:
When declaring a DECIMAL or NUMERIC column, the precision and scale can be (and usually is) specified; for example:
In this example, 5 is the precision and 2 is the scale. The precision represents the number of significant digits that are stored for values, and the scale represents the number of digits that can be stored following the decimal point. If the scale is 0, DECIMAL and NUMERIC values contain no decimal point or fractional part.
The number of digits before the decimal can be calculated by substracting scope from precion, and the number of digits after the decimal is the scope.
So the maximum of a DECIMAL(5,2) is 999.99, for DECIMAL(6,2) it is 9999.99, etc