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


Nice job! Before we move on, let's discuss the data types that work with ROUND() in PostgreSQL:

  • The single-argument function ROUND(x) accepts both numeric and double precision (floating-point number) data types.
  • If you want to round a number with precision to a specific decimal place with the two-argument ROUND(x, precision) function, the number being rounded must be either a numeric or a decimal type.

To round a floating point number and specify a precision at the same time, you have to first cast it as numeric. For example:

SELECT ROUND(weight::numeric, 2) AS rounded_weight
FROM character;

will round the weight to two decimal places.


Round height to two decimal places and show it as the rounded_height column.

Stuck? Here's a hint!

Here, you'll need this expression: ROUND(height::numeric, 2).