Reviewed by Aditya Kumar · Last reviewed 2026-08-08
The number of records resulting from a join depends on the join type and the cardinality of the join keys. An INNER JOIN returns m records (where m is the count of matching key combinations). A LEFT…
This medium-level SQL question appears frequently in data engineering interviews at companies like EY. 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. The expert answer includes a code example that demonstrates the implementation pattern.
The number of records resulting from a join depends on the join type and the cardinality of the join keys. An INNER JOIN returns m records (where m is the count of matching key combinations). A LEFT JOIN returns at least |A| records, and a RIGHT JOIN returns at least |B| records. A FULL OUTER JOIN returns |A| + |B| - m records.
LEFT and RIGHT joins, and the precise count for INNER joins, hinges on "row multiplication." If a single key from one table (e.g., Table A) matches multiple keys in the other table (Table B), the row from Table A will be duplicated for each corresponding match in Table B. This occurs in 1:N or N:M relationships. For instance, if Table A has a unique user_id but Table B contains five orders for that user_id, an INNER or LEFT JOIN on user_id will produce five rows for that specific user_id from Table A. LEFT JOIN guarantees all rows from Table A are present, padding with NULLs for non-matches in Table B. RIGHT JOIN does the inverse for Table B.
To validate the record count, always run a COUNT(*):
SELECT COUNT(*)
FROM table_a a
LEFT JOIN table_b b ON a.id = b.id;
COUNT() and COUNT(DISTINCT <join_key>) on both sides before and after* the join. Emphasize understanding the data's distribution and key uniqueness upfront to anticipate cardinality issues and design efficient, correct joins.Red Flag: Assuming without data—always validate. Pro-Move: 'We built a join validation suite: asserts expected cardinality from metadata; catches key definition bugs.'
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.