Kara_Krypton
Kara_Krypton

Reputation: 13

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:

EMP table

Upvotes: 1

Views: 66

Answers (1)

Eric
Eric

Reputation: 267

So add a:

count(DEPTNO) as NumberEmployeesInDept

to your select and I think you will be done.

Upvotes: 1

Related Questions