Multiple choice technology databases

Examine the statement of correlated subquery in the following cursor declaration. DECLARE CURSOR c1 IS SELECT D1.deptno, D1.loc, E1.Totalemp FROM dept D1, (SELECT deptno, COUNT(*) Totalemp FROM emp GROUP BY deptno) E1 WHERE D1.deptno = E1.deptno AND E1.Totalemp > 6; Why does this statement result in an error?

  1. Parameter has to be used in this cursor to make its execution successful.

  2. Correlated subquery cannot be used in CURSOR declaration.

  3. Correlated FROM clause subquery cannot be used in CURSOR declaration.

  4. AND logical operator cannot be used in WHERE clause of cursor declaration.

  5. No logical error.

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

This cursor declaration is valid SQL syntax. It joins the dept table with a subquery that aggregates employee counts by department. The subquery in the FROM clause is not correlated - it's an independent aggregation (GROUP BY deptno) that's then joined. There's no syntax error, no restriction against subqueries in cursor declarations, and the AND operator is perfectly valid in WHERE clauses.