Best April deals - hours only!Up to 80% off on all courses and bundles.-Close
Review
So you think you can count?
Rounding functions and more
15. The ROUND() function
Review and practice

Instruction

Good! Now you know how to subtract and divide in PostgreSQL, let's discuss other numeric functions. One of them is ROUND(x). This function will round the number within parentheses to the nearest integer number. This is standard mathematical rounding: any decimal part equal to or greater than 0.5 will be rounded up.

SELECT ROUND(account_balance)
FROM character
WHERE id = 1;

The above query will take the account_balance of the character with ID of 1 (which is 899.34) and round it to the nearest integer (to 899). Remember that ROUND() won't change the type of the value returned.

Exercise

For each character, show its name, its actual account_balance, and their account balance rounded to the nearest integer as the integer_balance column. Notice how rounding is applied.