How to round an average to 2 decimal places in PostgreSQL?

I am using PostgreSQL via the Ruby gem ‘sequel’.

I’m trying to round to two decimal places.

Here’s my code:

SELECT ROUND(AVG(some_column),2)    
FROM table

I get the following error:

PG::Error: ERROR:  function round(double precision, integer) does 
not exist (Sequel::DatabaseError)

I get no error when I run the following code:

SELECT ROUND(AVG(some_column))
FROM table

Does anyone know what I am doing wrong?

8 Answers
8

Leave a Comment