I have column zone_dist in my table parcel16 that contains land use codes (character). My objective is to create a two-column table which in the left-hand column shows all of the distinct values and in the right shows the total count of those values in the table, in descending order. I have tried with a basic query but cannot apply the sum function to a character value:
SELECT zone_dist, SUM(zone_dist) AS quantity
FROM parcel16
GROUP BY zone_dist
returns the error:
ERROR: function sum(character varying) does not exist
LINE 1: SELECT zone_dist, SUM(zone_dist) AS quantity
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
How would one go about taking the counts of all distinct character values?
countdon'tsum. Sum wan'ts to do math on character data, count simply counts occurances of zone_dist in parcel16.