Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

SQL Query, What have I done wrong? I am fairly new to mySQL

Solution
problem

SELECT agency_name, Count(*) AS complaint_type_count
FROM service_request_xs
GROUP BY agency_name
ORDER BY Count(*) DESC; 
  • solution uploaded

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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;
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading