From: Stephan Szabo <sszabo@megazone23.bigpanda.com>
To: Peter Atkins <Peter.Atkins@nextcard.com>
Cc: 'pgsql-sql@postgresql.org' <pgsql-sql@postgresql.org>
Subject: Re: type conversion?
Date: Tue, 9 Apr 2002 10:48:09 -0700 (PDT)
Message-ID: <20020409104600.H95735-100000@megazone23.bigpanda.com> (raw)
In-Reply-To: <02E689F991FFD311A75D009027B6A73E0886EAC7@corp_mail01.sf.nextcard.com>
On Tue, 9 Apr 2002, Peter Atkins wrote:
> I have a column "total_hours | character varying(5) " and I am unable to
> perform the aggrigate function SUM() because of the column type.
> Without changing the type is there a way to convert the datatype by using
> CAST(), to_char() or something simular? So that I may calculate the SUM().
>
> SELECT SUM(total_hours) AS hours FROM my_table WHERE flag='$flag';
I think this may work:
SELECT SUM(to_number(total_hours, '99999')) from my_table where ...
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: sszabo@megazone23.bigpanda.com, Peter.Atkins@nextcard.com
Subject: Re: type conversion?
In-Reply-To: <20020409104600.H95735-100000@megazone23.bigpanda.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox