Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Reviewing SQL and numbers
So you think you can count
Round and other functions
14. Function round()
Review and practice

Instruction

Good! Now that you know how to subtract and divide, we'll talk about other numerical 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) AS rounded_account_balance
FROM character
WHERE id = 1;

The above query will take the account_balance of the character with id = 1 (the account_balance is 899.34) and round it to the nearest integer (899 in this case).

Exercise

For each character, show its name, its account_balance and its account_balance rounded to the nearest integer (name this column rounded_account_balance). Notice how mathematical rounding is applied.