← Intuit Interview Insights

Intuit·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
May 2026

Summary

SQL interview at Intuit for a software engineer role. One meaty query question that looked straightforward at first but had a lot of moving parts once you got into the normalization and aggregation logic.

Questions Asked (1)

Q1

Given a transactions table with columns for transaction ID, status, amount, and a messy nullable reason field, write a SQL query that returns one row per status showing the total transaction count, total amount, and a concatenated string of the most common normalized failure reasons ordered by frequency.

Data ModelingProduct Analytics & MetricsTechnical Trade-offs
Author's notes

This one took me longer than I expected to get right.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the schema and the definition of 'normalized failure reasons' (e.g., lowercasing, trimming, mapping synonyms). Then outline a multi-step SQL approach: first normalize and aggregate reasons per status, then rank them by frequency, and finally aggregate transaction counts and amounts per status while concatenating the top reasons. Use window functions and string aggregation to produce the final result in one query.

Pro tip: Mention that you would handle NULLs and messy data by using COALESCE and TRIM/LOWER, and that you'd consider performance implications of window functions on large tables, possibly using a subquery or CTE to filter top reasons before joining.

1. Clarify requirements and data

Ask about the exact schema, what 'normalized' means (e.g., case-insensitive, removing punctuation), and whether 'most common' means top N overall or per status. Confirm if NULL reasons should be excluded or counted as a separate category.

2. Normalize and aggregate reasons

Write a CTE that selects status, normalized reason (e.g., LOWER(TRIM(reason))), and counts occurrences per status. Filter out NULLs or handle them explicitly.

3. Rank reasons by frequency per status

Use ROW_NUMBER() or RANK() OVER (PARTITION BY status ORDER BY count DESC) to identify the top reasons for each status. Decide on a cutoff (e.g., top 3) or include all if needed.

4. Aggregate transaction metrics per status

In a separate CTE or subquery, compute total transaction count and total amount per status from the original table.

5. Combine and concatenate reasons

Join the aggregated metrics with the ranked reasons, then use STRING_AGG (or GROUP_CONCAT) to concatenate the top reasons per status, ordered by frequency. Ensure the final output has one row per status.

Key Points to Mention

  • Use of CTEs for readability and modularity
  • Normalization techniques: LOWER, TRIM, REPLACE, and possibly mapping synonyms
  • Window functions (ROW_NUMBER, RANK) to rank reasons by frequency
  • String aggregation functions (STRING_AGG, GROUP_CONCAT) with ORDER BY
  • Handling NULLs and messy data (COALESCE, filtering)
  • Performance considerations: indexing, avoiding unnecessary sorting, and limiting top reasons

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.