SQL JOINS Interview Question | What does different SQL Joins return? | data engineer| data analysts

preview_player
Показать описание
Given 2 tables, identify the no of records returned using different type of SQL Joins. This is a very frequently asked SQL Interview questions especially when a recruiter wants to test your knowledge on SQL joins, this is the kind of questions you can expect.

In this video, we shall look at 2 different datasets. Each dataset contains 2 tables which has duplicate data, null values etc. You are required to identify the no of records returned using INNER Join, LEFT Join, RIGHT Join, FULL JOIN, Natural Join and Cross Join. And you need to answer them without querying the tables.

Hence in order to answer such questions, you need to understand clearly how SQL internally performs different type of joins.

How each SQL JOIN type works (INNER, LEFT, RIGHT, FULL)
How joins affect record counts in your SQL queries
Real-world examples using employee and department tables
Tips for optimizing JOIN queries for better performance
This tutorial is perfect for those preparing for SQL interviews or improving their data engineering skills. Make sure to subscribe for more SQL problems, coding tips, and data engineering interview questions!

NOTE:- Any Two NULLs are not same

/**8888888888******************************************************/
with Table1 as (
SELECT 'AAA' as ID
UNION ALL SELECT 'AAA' as ID
UNION ALL SELECT 'BBB' as ID
UNION ALL SELECT '' as ID
UNION ALL SELECT 'NULL' as ID
UNION ALL SELECT NULL as ID ),
Table2 as (
SELECT 'AAA' as ID
UNION ALL SELECT 'BBB' as ID
UNION ALL SELECT 'BBB' as ID
UNION ALL SELECT '' as ID
UNION ALL SELECT '' as ID
UNION ALL SELECT 'NULL' as ID
UNION ALL SELECT NULL as ID
)
SELECT Table1.ID as Table1ID, Table2.ID as Table2ID FROM Table1 Inner join Table2
ON Table1.ID = Table2.ID

/**8888888888******************************************************/
Given 2 tables, identify the no of records returned using different type of SQL Joins. This is a very frequently asked SQL Interview questions especially when a recruiter wants to test your knowledge on SQL joins, this is the kind of questions you can expect.

In this video, we shall look at 2 different datasets. Each dataset contains 2 tables which has duplicate data, null values etc. You are required to identify the no of records returned using INNER Join, LEFT Join, RIGHT Join, FULL JOIN, Natural Join and Cross Join. And you need to answer them without querying the tables.

Hence in order to answer such questions, you need to understand clearly how SQL internally performs different type of joins. #database fix
Рекомендации по теме
Комментарии
Автор

Hi, Thanks for the video! But when i try it on my database I'm getting 7 records for inner join do you know why? but you mentioned 8 in the document

dravid
Автор

a null can not be joined with other null so in inner join there should be just 7 records

AfzalAhmad-vmsj
welcome to shbcf.ru