简体   繁体   中英

Creating a one query list

List a count of the number of employees who work in either department 10 or 20, the average, minimum, and maximum employee salary in these departments, and a total of all their salaries combined (This question must be done by using one query)

MY CODE:

SELECT DEPTNO, AVG(SAL), MAX(SAL), MIN(SAL), SUM(SAL) AS TOTAL_SAL 
FROM EMP 
WHERE DEPTNO = 10 OR DEPTNO=20 
GROUP BY DEPTNO;

Table Schema:

电磁脉冲表

So add a:

count(DEPTNO) as NumberEmployeesInDept

to your select and I think you will be done.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM