Reviewed by Aditya Kumar · Last reviewed 2026-08-08
You cannot state a number without knowing the data, and saying so is the correct answer. Row counts depend on how many rows match on each side, not on the table sizes. What you can give is the…
This medium-level SQL question appears frequently in data engineering interviews at companies like Gartner. While less common, it tests deeper understanding that distinguishes strong candidates. Mastering the underlying concepts (join) will help you answer variations of this question confidently.
Break this problem into components. Identify the core trade-offs involved, then walk the interviewer through your reasoning step by step. Demonstrate awareness of edge cases and production considerations - this is what separates good answers from great ones.
You cannot state a number without knowing the data, and saying so is the correct answer. Row counts depend on how many rows match on each side, not on the table sizes. What you can give is the formula.
Let M be the number of rows produced by matching keys, Lu the left rows with no match, and Ru the right rows with no match.
M.M + Lu.M + Ru.M + Lu + Ru.Every outer join returns at least as many rows as the inner join, never fewer.
M is not "the number of matching keys". When a key appears multiple times on both sides, the join multiplies. If key A appears 3 times on the left and 2 times on the right, that key alone produces 6 rows.
Concretely, with a left table of 10 rows and a right table of 4:
A LEFT JOIN preserving "all left rows" is therefore a common misconception. It preserves every left row at least once, but duplicate right-side keys will fan those rows out.
They want to know whether you will notice an accidental fan-out. Unexpected row growth after a join is one of the most frequent data quality bugs in production pipelines, and it usually means the join key is not as unique as assumed.
In the interview, also mention that you would verify uniqueness with a quick GROUP BY key HAVING COUNT(*) > 1 before trusting a join's grain.
Red Flag: Guessing—run the query. Pro-Move: 'Interview tip: Ask for table sizes and join key relationship—then give precise formula with example.'
Some links below are affiliate links. If you buy through them we may earn a small commission at no extra cost to you — it helps keep DataEngPrep free.
According to DataEngPrep.tech, this is one of the most frequently asked SQL interview questions, reported at 1 company. DataEngPrep.tech maintains an editor-reviewed database of 1,863 data engineering interview questions across 7 categories.