Home > Back-end >  Excuse me method about data statistics by value
Excuse me method about data statistics by value

Time:09-25

The younger brother a beginner, I built two databases to store employees and department information, respectively to the other two modules increases the deletion operation, now I want to create a new module in the JSP page the pie chart shows the number of each department, could you tell me how to put all of the departments and the page count out the value to go up?

 

The CREATE TABLE ` employee ` (
` ID ` int (11), NOT NULL auto_increment,
` DEPT_ID ` int (11) NOT NULL,
` NAME ` varchar (20) NOT NULL,
PRIMARY KEY (` ID `),
The KEY ` FK_EMP_DEPT ` (` DEPT_ID `),
The CONSTRAINT ` FK_EMP_DEPT ` FOREIGN KEY (` DEPT_ID `) REFERENCES ` department ` (` ID `),
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

The CREATE TABLE ` department ` (
` ID ` int (11), NOT NULL auto_increment,
` NAME ` varchar (50) NOT NULL,
The PRIMARY KEY (` ID `)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CodePudding user response:

Select count (id), DEPT_ID from the employee GROUP BY DEPT_ID;

CodePudding user response:

Through group department id query count, it is concluded that the number of each department
  • Related