Multiple choice technology databases

Consider the emp table having columns empno, ename Which of the following SQL query fetches empno that occur more than twice in the emp table.

  1. select count() from emp group by empno having count() >2;

  2. select empno, count() from emp having count() >2;

  3. select empno, count() from emp where count() >2;

  4. select empno, count() from emp group by empno having count() >2;

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

To find employee numbers appearing more than twice, we need to: 1) Group by empno to aggregate occurrences, 2) Count occurrences with count(*), 3) Filter groups having count > 2 using HAVING clause. Option D correctly implements all three steps. Option A lacks the empno column in SELECT. Option B lacks GROUP BY. Option C incorrectly uses WHERE instead of HAVING for aggregate filtering.