Error Function Sumcharacter Varying Does Not Exist
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up error 'function sum(character varying) does not exist' using sum with SQL Alchemy and Postgres up vote 0 down vote favorite I get the following error when attempting use func.sum in my SQL Alchemy query: ProgrammingError: (ProgrammingError) function sum(character varying) does not exist LINE 1: SELECT airs.trip_type AS trip_type, sum(airs.total_including... ^ HINT: No function matches the given name and argument types. You might need to add explicit type casts. 'SELECT airs.trip_type AS trip_type, sum(airs.total_including_tax) AS total \nFROM airs GROUP BY airs.trip_type' {} CODE: model.py from datetime import datetime import hashlib from sqlalchemy.inspection import _self_inspects from werkzeug.security import generate_password_hash, check_password_hash from itsdangerous import TimedJSONWebSignatureSerializer as Serializer from markdown import markdown import bleach from flask import current_app, request, url_for from flask.ext.login import UserMixin, AnonymousUserMixin from app.exceptions import ValidationError from . import db, login_manager class Air(db.Model): __tablename__ = 'airs' id = db.Column(db.Integer, primary_key=True) booking_reference = db.Column(db.Integer) #, unique=True) company_name = db.Column(db.Unicode) trip_type = db.Column(db.Unicode) total_including_tax = db.Column(db.Unicode) importer.py query = db.session.query(Air.trip_type.
Reply | Threaded Open this post in threaded view ♦ ♦ | Report Content as Inappropriate ♦ ♦ How to convert string to integer 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 Szymon Lipiński Reply | Threaded Open this post in threaded view ♦ ♦ | Report Content as Inappropriate ♦ ♦ Re: [GENERAL] How to convert string to http://stackoverflow.com/questions/24134266/error-function-sumcharacter-varying-does-not-exist-using-sum-with-sql-alchem integer On 15 December 2010 11:23, venkat <[hidden email]> 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' but this will work only if for all rows you can convert http://postgresql.nabble.com/How-to-convert-string-to-integer-td3306037.html this field to integer regardsSzymon Guz Pavel Stehule Reply | Threaded Open this post in threaded view ♦ ♦ | Report Content as Inappropriate ♦ ♦ Re: How to convert string to integer In reply to this post by Venkat Tammineni Hello you can use a ::int for converting to integer. Or better - you can alter column to integer. It will be faster and more correct. Regards Pavel Stehule 2010/12/15 venkat <[hidden email]>: > 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 > > -- Sent via pgsql-sql mailing list ([hidden email]) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql Viktor Bojović Reply | Threaded Open this post in threaded view ♦ ♦ | Report Content as Inappropriate ♦ ♦ Re: How to convert string to integer In reply to this post by Venkat Tammineni On Wed, Dec 15, 2010 at 11:23
TABLE Sampletemp ( Sampleid serial NOT NULL, SampleText character varying(50), CONSTRAINT Sampletemp_id PRIMARY KEY (Sampleid));2. Insert into Sampletemp http://grokbase.com/t/postgresql/pgsql-general/118hrk7an2/type-casting-text-to-numeric-query-error (SampleText) values ('Mr. Raja'),('Mr. Alex'),('1000'),('2500'),('555');3. select sum(SampleText) as SampleText from Sampletemp;ERROR: https://github.com/Casecommons/pg_search/issues/13 function sum(character varying) does not existLINE 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 error function integer: "Mr. Raja"I am getting error while selecting using someaggregation.I would like to sum up thesevalues, if it has TEXT (example Name)that can be ZERO while querying. I need answeras 4055.Can i have yoursuggestion/solutions please?Regards,Vikram A reply Tweet Search Discussions Search All Groups PostgreSQL pgsql-general 3 responses Oldest Nested Pavel Stehule Hello 2011/8/17 Vikram error function sumcharacter A : SELECT sum(CASE WHEN sampletext ~ e'^\\d+$' THEN sampletext::int ELSE 0 END) FROM .. Regards Pavel Stehule p.s. better to use a two columns Pavel Stehule at Aug 17, 2011 at 12:31 pm ⇧ Hello2011/8/17 Vikram A