Rainbow Deals - hours only!Up to 80% off on all courses and bundles.-Close
Date and time


Good! That was a rather peculiar result, wasn't it? Let's see how we can fix it.

What kind of data is most important for every business? Money, of course. Because of rounding errors, floating point numbers are not suitable to store money values. After all, we don't want the bank to think that we ALMOST or NEARLY paid back the credit!

Money values can be stored in another data type: DECIMAL. What is unique about this data type is that it stores numbers in the decimal system.

DECIMAL values are precise when they are added or divided by integer numbers. This is why they are an excellent choice for financial operations like calculating tax.

In SQL, DECIMAL(p,s) takes two numbers: p is the precision (that is, the number of digits in the number) and s stands for the scale (the number of digits after the decimal point). DECIMAL(5,2) is a number which has 5 digits, of which 2 are after the decimal point.


The online dating business is going really well and Peter needs another table where he will keep money transfers from his users. Create a simple table payment with two columns: user_id which stores integer values and amount which is a decimal value with 6 digits, of which 2 are after the decimal point.

Stuck? Here's a hint!


CREATE TABLE payment (
    user_id int,
    amount decimal(6,2)