It is used to group a set of rows with the same values specified columns into summary rows. Useful for aggregate statistics for each group, such as average, total quantity, max/min values.
The first query groups the results by state_province and city, and counts the number of companies in each city within each state_province. The second query just counts the total number of companies.