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

How do i sort the "DeptNumberCount" from largest to lowest?

SELECT DeptName , COUNT(*) AS "DeptNumberCount"
FROM Department
GROUP BY DeptName

This is the code i’m running that im working on for SQL but i’m trying to get the count to show up first then the deptname, but it doesn’t allow me to and i need to have it so it’s largest to smallest.

Can someone please help

I’ve tried putting:

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

GROUP BY "DeptNumberCount" , DeptName or 
GROUP BY DeptNumberCount , DeptName

And the HAVING clause is giving me a syntax

>Solution :

Try ordering descending by the department count:

SELECT COUNT(*) AS "DeptNumberCount", DeptName
FROM Department
GROUP BY DeptName
ORDER BY COUNT(*) 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