[postgis-users] How to take sum of varchar column ?

Marcin Mionskowski mionskowskimarcin at gmail.com
Thu May 16 20:46:46 PDT 2019


How do you want to sum your VARCHAR column? What kind of values are
stored in that column?
And how is your question in the topic related to the content of your
email?
And what do you mean by "but not with where command"?

If you want just this one code (EGLL), than you can do (with WHERE):
SELECT count(distinct airport_id) 
FROM example_table 
WHERE upper(icao_cd)='EGLL';
-- count distinct if you have non-unique airport_id's

If you want all of the codes, do (without WHERE:):
SELECT upper(icao_cd), count(distinct airport_id) 
FROM example_table 
GROUP BY upper(icao_cd);

Marcin

W dniu czw, 16.05.2019 o godzinie 21∶11 +0100, użytkownik Taylan
Karakurt napisał:
> Hello everyone,
> 
> I have an example job from my client and figuring out it with
> postgresql. I imported the csv data which is approx. 3 million rows.
> I'm trying to get for example how many airport id has EGLL code but
> not with where command. Tried to sum but didnt work. We were doing
> same thing before at my previous job. Every help appreciated. 
> 
> _______________________________________________
> postgis-users mailing list
> postgis-users at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/postgis-users



More information about the postgis-users mailing list