What does GROUP BY do in SQL, and when would you use HAVING?

Prepare for the TJR Bootcamp Test with quizzes and flashcards. Each question includes hints and explanations to boost your readiness for the exam!

Multiple Choice

What does GROUP BY do in SQL, and when would you use HAVING?

Grouping in SQL is about combining rows that share the same values in one or more columns into a single summary row. After you group, you typically apply aggregate functions like SUM, COUNT, AVG, or MAX to produce a result for each group. HAVING is what you use to filter those grouped results based on conditions that involve those aggregates. For example, you might want to show only groups where the total sales exceed a threshold. It’s different from filtering individual rows with WHERE, which runs before grouping; HAVING filters after the grouping and aggregation are done. This combination—grouping by columns and then applying a filter to the groups—is what the correct option describes.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy