[英]SQL query using group by
I have a table called "EMP" and two collumns one called "deptno" and the other called "job". 我有一个名为“EMP”的表和两个名为“deptno”的列,另一个称为“作业”。 I need a query to find out how many people there are in each type of job within each department.
我需要一个查询来查明每个部门中每种工作类型的人数。
I know I need to use count() and group by but im not sure how to do this, any help would be appreciated. 我知道我需要使用count()和group by但我不知道如何做到这一点,任何帮助将不胜感激。
Thanks James. 谢谢詹姆斯。
select job, deptno, count(*) as people
from emp
group by job, deptno
SELECT JOB, DEPTNO, count(1) AS EMP_COUNT
FROM EMP
GROUP BY JOB, DEPTNO;
Try This 尝试这个
select job, deptno, count(*) as TotEmp
from emp
group by job, deptno
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.