Solution: Use NUMERIC Data Type

Let's solve the antipattern by using the NUMERIC data type.

We'll cover the following...

Instead of FLOAT or its siblings, let’s use the NUMERIC or DECIMAL SQL data types for fixed-precision fractional numbers.

Press + to interact
ALTER TABLE Bugs ADD COLUMN hours NUMERIC(9,2);
ALTER TABLE Accounts ADD COLUMN hourly_rate NUMERIC(9,2);

Precision and scale

The NUMERIC and DECIMAL data types store numeric values exactly, up to the precision we specify in the column definition. We can specify precision as an argument to the data type, similar to the syntax we would use for the length of a VARCHAR data type. The precision is the total number ...