Received: from beamish.nsd.ca (unknown [205.150.156.194]) by postgresql.org (Postfix) with ESMTP id 246F9475E06 for ; Tue, 9 Apr 2002 13:50:42 -0400 (EDT) Received: (from smap@localhost) by beamish.nsd.ca (8.9.3/8.9.3) id NAA01506; Tue, 9 Apr 2002 13:50:40 -0400 X-Authentication-Warning: beamish.nsd.ca: smap set sender to using -f Received: from reddog.nsd.ca(192.168.101.30) by beamish.nsd.ca via smap (V2.1/2.1+anti-relay+anti-spam) id xma001504; Tue, 9 Apr 02 13:50:30 -0400 Received: from nsd.ca (jllachan-linux.nsd.ca [192.168.101.148]) by reddog.nsd.ca (8.8.7/8.8.7) with ESMTP id NAA19773; Tue, 9 Apr 2002 13:50:29 -0400 Message-ID: <3CB32A0D.D02958A6@nsd.ca> Date: Tue, 09 Apr 2002 13:51:09 -0400 From: Jean-Luc Lachance X-Mailer: Mozilla 4.77 [en] (X11; U; Linux 2.4.9-31 i686) X-Accept-Language: en MIME-Version: 1.0 To: Peter Atkins Cc: "'pgsql-sql@postgresql.org'" Subject: Re: type conversion? References: <02E689F991FFD311A75D009027B6A73E0886EAC7@corp_mail01.sf.nextcard.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Archive-Number: 200204/103 X-Sequence-Number: 7368 Try: SELECT SUM(int4(total_hours)) AS hours FROM my_table WHERE flag='$flag'; JLL Peter Atkins wrote: > > All, > > 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'; > > Thanks! > -p > > ---------------------------(end of broadcast)--------------------------- > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org