Machine-translated by Google. Questions are authored in English.
Top

Discussion

The HAVING clause acts like a WHERE clause, but it identifies groups that meet a criterion, rather than rows.

  • A.True
  • B.

    False

Answer: A

Correct answer: True

HAVING is the group-level counterpart of WHERE. It runs after GROUP BY has formed the groups and after the aggregates have been computed, so it can test them: HAVING COUNT(*) > 5 keeps only groups with more than five rows.

WHERE runs earlier, deciding which rows enter the groups, and cannot refer to an aggregate because at that point no group exists. Filtering on a plain column therefore belongs in WHERE, where it reduces the rows to be grouped, not in HAVING.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.