here's query is:
select a.cartodb_id cartdb_id, a.identifier store, (select count(*) full_data_for_testing_deid_2) ,count(b.*) customer_count demo_locations_table a, full_data_for_testing_deid_2 b st_dwithin(a.the_geom::geography,b.the_geom::geography,16093) group a.cartodb_id and here's comes back:
| cartdb_id | store | count | customer_count | |-----------|-----------------|-------|----------------| | 1 | store number: 1 | 32085 | 30 | | 2 | store number: 2 | 32085 | 283 | | 3 | store number: 3 | 32085 | 609 | | 4 | store number: 4 | 32085 | 61 | | 5 | store number: 5 | 32085 | 325 | in case, count equals total number of customers (one row per customer) in table. want column shows percentage of customers per store: customer_count divided count, can't figure out how integrate query. ps: don't need count column. included reference.
thanks.
select a.cartodb_id cartdb_id, a.identifier store, count(b.*) customer_count , count(b.*)/(select count(*) full_data_for_testing_deid_2)*100 percentage demo_locations_table a, full_data_for_testing_deid_2 b st_dwithin(a.the_geom::geography,b.the_geom::geography,16093) group a.cartodb_id
Comments
Post a Comment