Skip site navigation (1) Skip section navigation (2)


From: Eduardo Vázquez Rodríguez <evazquez(at)insys-corp(dot)com(dot)mx>
To: pgsql-novice(at)postgresql(dot)org
Subject: Cast
Date: 2004-09-08 21:29:26
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-novice
I made I mistake choosing the data types in my database I try to run  a 
query that look like this
Duration data type is varchar

SELECT name, SUM(duration) AS total
FROM table
HAVING  name != 'John'

I get the following error:
ERROR:  function sum(character varying) does not exist
HINT:  No function matches the given name and argument types. You may 
need to add explicit type casts.

1. How can I made a cast on the query from varchar to int?

2. If I change the datatype on the database from varchar to int, do I 
loose all the data on that field?

Thanks in advanced


  • Re: Cast at 2004-09-08 23:18:36 from Gaetano Mendola

pgsql-novice by date

Next:From: Gaetano MendolaDate: 2004-09-08 23:18:36
Subject: Re: Cast
Previous:From: Ron St-PierreDate: 2004-09-08 15:11:56
Subject: Re: I NEED HELP!!! - (ERROR: parser: unterminated quoted

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group