โ† All SQL Flashcard Decks

Aggregate Functions and Grouping Flashcards

7 cards from real SQL practice questions. Tap to flip, then mark Knew It or Still Learning โ€” missed cards come back until you master them.

Read the first 7 Aggregate Functions and Grouping flashcards as text
  1. Which aggregate function returns the total number of rows, including those with NULL values in the counted column?

    Answer: COUNT(*)

    COUNT(*) counts every row regardless of NULLs, while COUNT(column) skips NULLs.

  2. What does AVG(salary) ignore when computing the average?

    Answer: NULL values

    AVG ignores NULL rows entirely, dividing the sum by the count of non-NULL values.

  3. In a query with GROUP BY department, which column can appear in SELECT without being aggregated?

    Answer: department

    Only the grouping column(s) may appear ungrouped and unaggregated in the SELECT list.

  4. Which clause filters groups based on an aggregate condition like SUM(amount) > 1000?

    Answer: HAVING

    HAVING applies conditions to grouped results after aggregation, unlike WHERE.

  5. What is the result of COUNT(DISTINCT city) on a column with values 'NY','NY','LA',NULL?

    Answer: 2

    DISTINCT counts unique non-NULL values, so 'NY' and 'LA' give 2.

  6. Which function returns the largest value in a numeric column?

    Answer: MAX

    MAX returns the highest value among the rows in each group or set.

  7. In the logical order of execution, when is GROUP BY processed relative to WHERE?

    Answer: After WHERE

    WHERE filters rows first, then GROUP BY groups the remaining rows.