SELECT agency_name, Count(*) AS complaint_type_count FROM service_request_xs GROUP BY agency_name ORDER BY Count(*) DESC;
- solution uploaded
Advertisement
Answer
You have to tell the count() function what to count. You can insert an individual column, or * for all of it etc. But you have to count something.
This is a fiddle, showing how it works: https://www.db-fiddle.com/f/dbPnE4BXv8oRRkQY4WQs8v/1
SELECT agency_name, COUNT(DISTINCT compliant_type) AS complaint_type_count FROM service_request_xs GROUP BY agency_name ORDER BY COUNT(DISTINCT compliant_type) DESC;