Multiple choice technology databases

What is the output of the below queries: if table A is having 16 rows: select count() from A where 10=10; select count() from A having 10=10;

  1. first gives error, 16

  2. 16, second gives error

  3. 16,16

  4. Both the queries will give error

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

The first query with WHERE 10=10 is always true, so count() returns 16. The second query uses HAVING 10=10 on an aggregate - this operates on the single result row from count() and returns 16 since the condition is always true. Both return 16. HAVING without GROUP BY applies to the entire result set as a single group.