'Easiest way to group and count in SQL

Question: Show all of the patients grouped into weight groups. Show the total amount of patients in each weight group.

What I have so far:

SELECT COUNT(CASE WHEN weight >=0 and weight <=10 THEN 1 ELSE NULL END) AS patients_in_group1,
       COUNT(CASE WHEN weight >=11 and weight <=20 THEN 1 ELSE NULL END) AS patients_in_group2,
       COUNT(CASE WHEN weight >=21 and weight <=30 THEN 1 ELSE NULL END) AS patients_in_group3,
       COUNT(CASE WHEN weight >=31 and weight <=500 THEN 1 ELSE NULL END) AS patients_in_group4
FROM patients
sql


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source