Re: SQL error: function round(double precision, integer) does not exist - Mailing list pgsql-sql

From Michael Fuhr
Subject Re: SQL error: function round(double precision, integer) does not exist
Date
Msg-id 20050228163309.GA105@winnie.fuhr.org
Whole thread Raw
In response to SQL error: function round(double precision, integer) does not exist  (TJ O'Donnell <tjo@acm.org>)
Responses Re: SQL error: function round(double precision, integer) does
List pgsql-sql
On Sun, Feb 27, 2005 at 03:26:07PM -0800, TJ O'Donnell wrote:

> ERROR:  function round(double precision, integer) does not exist                        ^^^^^^^^^^^^^^^^
[snip]

> The functions described at:
> http://www.postgresql.org/docs/7.4/static/functions-math.html
> show that round(numeric,int) should work ok.                 ^^^^^^^

The two-argument form of round() expects the first argument to be
numeric, not double precision.  There's no implicit cast from double
precision to numeric, so you'll have to use an explicit cast:

SELECT ... round((expression)::numeric, 2) ...

-- 
Michael Fuhr
http://www.fuhr.org/~mfuhr/


pgsql-sql by date:

Previous
From: Kai Hessing
Date:
Subject: Re: Software for database-visualisation
Next
From: Bruno Wolff III
Date:
Subject: Re: diference in dates in minutes