Given two tables EMPLOYEE (EID, ENAME, DEPTNO) DEPARTMENT (DEPTNO, DEPTNAME)…

2019

Given two tables

EMPLOYEE (EID, ENAME, DEPTNO)

DEPARTMENT (DEPTNO, DEPTNAME)

Find the most appropriate statement of the given query:

Select count (*) ‘total’

from EMPLOYEE

where DEPTNO IN (D1,D2)

group by DEPTNO

having count (*) >5

  1. A.

    Total number of employees in each department 𝐷1 and 𝐷2

  2. B.

    Total number of employees of department 𝐷1 and 𝐷2 if their total is >5

  3. C.

    Display total number of employees in both departments 𝐷1 and 𝐷2

  4. D.

    The output of the query must have at least two rows

Attempted by 426 students.

Show answer & explanation

Correct answer: B

The query groups employees by DEPTNO and counts the number of employees in each department. It only considers departments D1 and D2 due to the IN clause. The HAVING clause filters the results to include only those departments where the count of employees is greater than 5. Therefore, the output shows the count of employees for each of D1 and D2 only if that count exceeds 5.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Mppsc Assistant Professor