X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B698D56459 for ; Mon, 28 Feb 2005 17:12:37 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 68149-06 for ; Mon, 28 Feb 2005 17:12:33 +0000 (GMT) Received: from fed1rmmtao05.cox.net (fed1rmmtao05.cox.net [68.230.241.34]) by svr1.postgresql.org (Postfix) with ESMTP id DE2ED54EBF for ; Mon, 28 Feb 2005 17:12:30 +0000 (GMT) Received: from [192.168.1.200] (really [68.111.226.8]) by fed1rmmtao05.cox.net (InterMail vM.6.01.04.00 201-2131-118-20041027) with ESMTP id <20050228171225.YSTL7956.fed1rmmtao05.cox.net@[192.168.1.200]>; Mon, 28 Feb 2005 12:12:25 -0500 Message-ID: <422350F6.1050106@acm.org> Date: Mon, 28 Feb 2005 09:12:22 -0800 From: TJ O'Donnell Reply-To: tjo@acm.org User-Agent: Mozilla Thunderbird 0.9 (Windows/20041103) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Michael Fuhr Cc: pgsql-sql@postgresql.org Subject: Re: SQL error: function round(double precision, integer) does References: <4222570F.5080901@acm.org> <20050228163309.GA105@winnie.fuhr.org> In-Reply-To: <20050228163309.GA105@winnie.fuhr.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.003 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200502/355 X-Sequence-Number: 20465 I got round(numeric,int) working OK, but it's got me thinking (a dangerous thing!). Is there some fundamental reason for round(dp) but round(numeric,int)? Shouldn't they be, at least, consistent, having round(numeric) or round(dp,int)? Am I missing something? Thanks, TJ Michael Fuhr wrote: > 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) ... >