Essential cookies keep authentication working. With your permission, we also use analytics cookies to understand and improve the product. Read our Privacy Policy

DataEngPrep.tech
QuestionsPracticeAI CoachDashboardPricingBlog
ProLogin
Home/Questions/SQL/How many records result from Inner Join, Left Join, Right Join given Table A and Table B?

How many records result from Inner Join, Left Join, Right Join given Table A and Table B?

SQLmedium2 min read

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…

🤖 Analyze Your Answer
Frequency
Low
Asked at 1 company
Category
487
questions in SQL
Difficulty Split
130E|271M|86H
in this category
Total Bank
1,863
across 7 categories
Asked at these companies
EY
Key Concepts Tested
join

Why This Question Matters

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.

How to Approach This

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.

Expert Answer
341 wordsIncludes code

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.

Mechanics of Row Multiplication

The "at least" qualification for 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.

Performance Implications and Trade-offs

This "row multiplication" can significantly inflate dataset sizes, impacting query performance and storage costs. In distributed systems like Apache Spark, it can lead to substantial data shuffling across partitions, becoming a major bottleneck. For data warehouses like Snowflake, increased row counts mean more micro-partitions to scan and more compute consumed. Data engineers must understand the expected cardinality of their join keys to prevent unintended data explosions, which can also break assumptions in downstream dbt models or data quality checks.

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;

In the interview, also mention…

Always validate your join results with 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.
⚡
Pro Tip

Red Flag: Assuming without data—always validate. Pro-Move: 'We built a join validation suite: asserts expected cardinality from metadata; catches key definition bugs.'

Want all answers as a PDF for offline study?
Seven focused volumes with 750+ in-depth answers — Answer Vault →

Related SQL Questions

mediumWrite an SQL query to find the second-highest salary from an employee table.FreemediumDemonstrate the difference between DENSE_RANK() and RANK()FreemediumDiscuss differences between ROW_NUMBER(), RANK(), and DENSE_RANK(), and provide examples from your projects.FreemediumExplain the differences between Data Warehouse, Data Lake, and Delta LakeFreemediumExplain the differences between Repartition and Coalesce. When would you use each?Free

Level up your prep

Recommended
Educative
Educative Unlimited

800+ hands-on courses — Grokking System Design, Coding Patterns, and AI mock interviews for your DE loop.

Start learning →

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.

← Back to all questionsMore SQL questions →
Categories
All QuestionsSQLSpark / Big DataPython / CodingSystem DesignCloud / ToolsBehavioral
By Company
AmazonGoogleDatabricksSnowflakeAWSAzureMicrosoftNetflixUberTCS
Interview Guides
All GuidesTop SQL QuestionsTop Spark QuestionsPySpark QuestionsTop Python QuestionsTop System DesignKafka QuestionsAirflow QuestionsSQL Window FunctionsETL QuestionsData Modeling
Products
AI Interview CoachAnswer AnalyzerSQL PlaygroundResume AnalyzerAnswer Vault PDFsPricing
Company
About & Editorial PolicyContact UsAI DisclosureDisclaimerTerms of ServicePrivacy Policy
© 2026 DataEngPrep.tech. All rights reserved.
AboutBlogContactDisclaimer