How does mysql, find out the number of people in a company and a department at a time?

as shown in the figure above, how to use the MySQL statement to find out the number of people in the company and each department at a time?

Mar.09,2021

 

find out at once? This can add a derivative column, but it doesn't make any sense. Do you want to see the proportion of people in each department?

check the number of departments (if you can't put quotation marks on the list name, the syntax should be correct):
SELECT department name, COUNT (*) number of departments
FROM table
GROUP BY department name

check the total number of people:
SELECT COUNT (*)
from table

Menu