use group by and order by with count in sql code example Example: sql count group by SELECT gender, COUNT(*) FROM people GROUP BY gender;