# Thread: MySQL Data type for percent

1. Registered User
Join Date
Jan 2004
Posts
6

## Unanswered: MySQL Data type for percent

I am trying to set up 2 columns.
One is for Price in US dollars.
Two is for the percent markup (of the above Price).

Examples:
\$100.00 for Price
10.5% for percent markup

So the resulting purchase price would be Price plus percent markup.
In this case it would be \$110.50

I understand that DECIMAL 4,2 would be the approprate data type for the Price column.

What would be appropriate data type for the percent markup column?

2. Registered User
Join Date
Mar 2004
Posts
480
Use decimal for that as well. You would write 10.5% as .105
you would need to use decimal (4,3) for that as you might need to represent a 100% or more markup.

Also you might find you need to use the round() function when doing your calculations to get the right number of decimals for your price.

3. SQL Consultant
Join Date
Apr 2002
Location
Posts
20,002
the largest number that decimal(4,2) can hold is 99.99

the largest number that decimal(4,3) can hold is 9.999

4. Registered User
Join Date
Mar 2004
Posts
480
Well I was thinking that he would represent 10% as .1 and 100% as 1.00, the ,3 would be needed to represent the third digit of 1/2 percent as .005

Too many baseball stats for me I guess, since I'm used to representing a '300' batting average as .300
Last edited by guelphdad; 05-09-04 at 01:24.

5. SQL Consultant
Join Date
Apr 2002
Location