From: | Vikram A <vikkiatbipl(at)yahoo(dot)in> |
---|---|
To: | PGSQL - Genearal <pgsql-general(at)postgresql(dot)org> |
Subject: | Type casting text to Numeric - Query Error |
Date: | 2011-08-17 12:17:23 |
Message-ID: | 1313583443.12490.YahooMailNeo@web137417.mail.in.yahoo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi there,
I have the following definitions,
1. CREATE TABLE Sampletemp ( Sampleid serial NOT NULL, SampleText character varying(50), CONSTRAINT Sampletemp_id PRIMARY KEY (Sampleid));
2. Insert into Sampletemp (SampleText) values ('Mr. Raja'),('Mr. Alex'),('1000'),('2500'),('555');
3. select sum(SampleText) as SampleText from Sampletemp;
ERROR: function sum(character varying) does not exist
LINE 3: select sum(SampleText) as SampleText from Sampletemp;
^
HINT: No function matches the given name and argument types. You may need to add explicit type casts.
4. select sum(SampleText :: int) as SampleText from Sampletemp;
ERROR: invalid input syntax for integer: "Mr. Raja"
I am getting error while selecting using some aggregation.
I would like to sum up these values, if it has TEXT (example Name)that can be ZERO while querying. I need answer as 4055.
Can i have your suggestion/solutions please?
Regards,
Vikram A
From | Date | Subject | |
---|---|---|---|
Next Message | Pavel Stehule | 2011-08-17 12:30:31 | Re: Type casting text to Numeric - Query Error |
Previous Message | alexondi | 2011-08-17 11:41:23 | Re: Change master to standby |