You can see the Count command before using GROUP BY command here. GROUP BY
command will create groups in the field name specified and will count the number
of records in the groups. This is very useful command.
We can also use WHERE command along with GROUP BY command in Mysql tables.
SELECT count(*) as total_records, class FROM `student` group by class
This will display the total records in each class. Like this
Let us try to get the total number of girls records in each class by using GROUP BY query. Here we want to filter our query for only girls so we have to use one WHERE clause to restrict the records using the sex field. Here is the query.
SELECT count( * ) AS total_records, class FROM `student` WHERE sex='female' GROUP BY class