Name the input rows and the output grain of each aggregate.
Review row and value counts, grouped sums, HAVING, filtered totals, distinct counts and an outer maximum.
The section counts matching outcomes on six supplied SQLite 3.53.4 tasks. It is not a professional level, percentile, employer cutoff or qualification. Every explanation and all four full guides remain available regardless of count.
Five ticket rows support six different questions
The setup contains two departments, five ticket rows and one missing numeric value. The same data can answer several different aggregate questions: how many rows exist, how many values are non-NULL, each department’s sum, which grouped total passes a threshold and the largest of those totals. Do not replace one question with another merely because both return a small number. Read the selected expression and the input filtering before calculating it.
An empty sum is not the number zero
In a new unscored example, a payments table contains the value four. Filter it with WHERE v>9 and select COUNT(*), SUM(v). The result is one row displayed as 0|NULL. The count reports zero retained rows, while SUM has no non-NULL value to add and returns NULL. This does not remove the aggregate result row. Supplying COALESCE would be a separate decision that the shown statement has not made.
Count rows, values or distinct departments deliberately
COUNT(*) counts input rows, including a row whose numeric value is NULL. COUNT(value) ignores that missing value. COUNT(DISTINCT dept) instead counts the two distinct supplied department strings. These counts have different units even when they happen to match on other inputs. State the unit beside the result rather than treating every COUNT call as interchangeable. The bank’s explicit data contains no missing department string to introduce a further case.
Apply WHERE before grouping and HAVING to groups
The filtered-sum task retains only qualifying numeric rows before SUM evaluates them. The separate HAVING task groups the supplied rows and tests each group’s sum against a strict threshold. Moving the same-looking numeric condition between these positions can change the request. Work through the retained rows, then the groups and their totals in order. Keep an exact boundary such as greater than ten distinct from greater than or equal to ten.
Keep the inner total separate from the outer maximum
The nested query first creates one total per department and names that result column total. The outer MAX then compares those totals, not individual ticket values. For the supplied rows, the largest ticket and the largest department total differ. Draw the intermediate two-row result before reading the outer SELECT. The small integer inputs avoid overflow and floating-point questions; this exercise does not establish the precision of arbitrary production financial calculations.
Change a group’s membership before changing its formula
Create a disposable in-memory table with invented labels and a few integer values. Predict COUNT(*) and COUNT(value), then add one NULL value and predict again. Next change one group member and compare its sum with the maximum of all group sums. Write each intermediate result before executing. The website needs no uploaded spreadsheet or private database connection; the suggested exercise uses synthetic input that you can discard after reviewing the output.
Interpret the count as a review pointer
Six matching keys can guide revision, but the count alone cannot show whether you chose the right grain for an unfamiliar report, reconciled its totals or designed an efficient query. All worked explanations and all four complete guides remain available regardless of count. Outcomes were checked in the stated SQLite 3.53.4 environment. No percentile, professional band, employer threshold or certificate is assigned, and retaking this fixed bank after reading the keys can reward memory.