Programming · Flashcard

What is the difference between WHERE and HAVING?

  • AWHERE filters rows before grouping while HAVING filters groups after aggregation
  • BWHERE filters numeric values while HAVING is the equivalent for text columns
  • CWHERE works in plain queries while HAVING replaces it whenever joins are used
  • DWHERE is evaluated last while HAVING runs first to reduce the grouping work

Why this is the answer

WHERE runs on individual rows before GROUP BY; HAVING runs on the grouped result and may use aggregates. The distinction has nothing to do with data types or joins, and the order in the last option is reversed — WHERE first, HAVING later.

Official docs
Study in Gnoseed →