SQL Aggregation Quant Interview Guide
SQL aggregation quant interview guide for count, sum, average, groupby, having, nulls, duplicates, examples, and checks.
Candidates computing grouped metrics, counts, and summary statistics.
Aggregation changes the row grain
An aggregate query turns many rows into fewer rows. State the output grain, such as one row per symbol, user, date, or experiment group.
Nulls and duplicates affect metrics
COUNT star, COUNT column, AVG, SUM, and DISTINCT each handle missing or duplicate data differently. Choose intentionally.
Concrete example
Average order size can mean average across orders, across users, or across user-days. Those are different GROUP BY choices.
HAVING filters aggregated groups
WHERE filters rows before aggregation. HAVING filters groups after aggregation, such as symbols with more than a threshold number of trades.
Common mistakes
Candidates often compute a metric at the wrong grain. Write the desired output row before writing the aggregate query or grouping columns.
Practice the pattern
Use the LeetQuidity curriculum and calibration to turn this topic into a focused practice plan.