Re: [SQL] How to convert string to integer

From: Viktor Bojović <viktor(dot)bojovic(at)gmail(dot)com>
To: venkat <ven(dot)tammineni(at)gmail(dot)com>
Cc: Postgres General <pgsql-general(at)postgresql(dot)org>, pgsql-sql(at)postgresql(dot)org
Subject: Re: [SQL] How to convert string to integer
Date: 2010-12-15 10:37:34
Message-ID: AANLkTikutYUZxGkjSe4tSGwgsS+9v2HY9j_qkm+ehgVH@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-sql

On Wed, Dec 15, 2010 at 11:23 AM, venkat <ven(dot)tammineni(at)gmail(dot)com> wrote:

> Dear All,
>
> How do i convert string to int
>
> select SUM(pan_1) from customers1 where name='101'
>
> When i run the above query i m getting "function sum(character varying)
> does not exist"..
>
> Please anyone can guide me..
>
> Thanks
>
>
>
select SUM(pan_1::integer) from customers1 where name='101'

also you can use conversion functions described here
http://www.postgresql.org/docs/8.2/static/functions-formatting.html

--
---------------------------------------
Viktor Bojović
---------------------------------------
Wherever I go, Murphy goes with me

In response to

Browse pgsql-general by date

  From Date Subject
Next Message tuanhoanganh 2010-12-15 11:04:41 Re: How to restore from backup to 8.4.3 server using 9.0 dump/restore
Previous Message Laurent Wandrebeck 2010-12-15 10:37:10 Re: Linux: PAE or x64

Browse pgsql-sql by date

  From Date Subject
Next Message Alberto 2010-12-15 15:12:38 Database consistency after a power shortage
Previous Message Pavel Stehule 2010-12-15 10:27:50 Re: [SQL] How to convert string to integer