Find the output after every JOIN like Left, Right & inner.

  Рет қаралды 2,250

The Big Data Show

The Big Data Show

3 ай бұрын

Пікірлер: 9
@santypanda4903
@santypanda4903 2 ай бұрын
Is this the full video? Where is the link? I thought it got abruptly cut at the end.
@Someonner
@Someonner 2 ай бұрын
AMEX also asks the same question
@vabz_parab
@vabz_parab 2 ай бұрын
Record count for 'NULL' in case of LEFT JOIN should be 2. Not 4 (Wrong output shown in the last)
@TheBigDataShow
@TheBigDataShow 2 ай бұрын
It will actually be 4. One NULL will create 2 rows after joining with the other 2 NULL of the right table and then the next NULL will again join with 2 NULL of the right table. Kindly generate these tables in MySQL and cross check this.
@TheBigDataShow
@TheBigDataShow 2 ай бұрын
I think you are right. If only checked with NULL then the value will be different. I have used the following query ``` WITH JoinedData AS ( SELECT t1.id AS FirstTableID, t2.id AS SecondTableID FROM FirstTable t1 LEFT JOIN SecondTable t2 ON t1.id = t2.id OR (t1.id IS NULL AND t2.id IS NULL) ) SELECT COALESCE(FirstTableID, 'NULL') AS JoinKey, COUNT(*) AS RecordCount FROM JoinedData GROUP BY COALESCE(FirstTableID, 'NULL'); ``` The output will be this { "1": 2, "2": 1, "3": 2, "NULL": 4 } If you will use simple join then ``` WITH JoinedData AS ( SELECT t1.id AS FirstTableID, t2.id AS SecondTableID FROM FirstTable t1 LEFT JOIN SecondTable t2 ON t1.id = t2.id ) SELECT FirstTableID, COUNT(*) AS RecordCount FROM JoinedData GROUP BY FirstTableID; ``` Here in the second query NULL values in FirstTable do not match with any NULL in SecondTable. Output { "LEFT JOIN": { "1": 2, "2": 1, "3": 2, "NULL": 2 } }
@TheBigDataShow
@TheBigDataShow 2 ай бұрын
@vabz_parab thank you for correction
@vabz_parab
@vabz_parab 2 ай бұрын
@@TheBigDataShow thanks and welcome!! And I liked your 1st query approach too. Seems interesting 👍🏻
@m04d10y1996
@m04d10y1996 21 күн бұрын
Null doesn't join with itself.​@@TheBigDataShow
女孩妒忌小丑女? #小丑#shorts
00:34
好人小丑
Рет қаралды 31 МЛН
Чёрная ДЫРА 🕳️ | WICSUR #shorts
00:49
Бискас
Рет қаралды 3,7 МЛН
What does a Data Analyst actually do? (in 2024) Q&A
14:27
Tim Joo
Рет қаралды 45 М.
GCP Data Engineer Mock  interview
15:22
Grow With Google Cloud
Рет қаралды 1,7 М.
Database vs Data Warehouse vs Data Lake | What is the Difference?
5:22
Alex The Analyst
Рет қаралды 765 М.
Fresher Mock Interview SQL | Technical Round | SQL Interview for Fresher | HR Interview
14:50
Lotus IT Hub training institute
Рет қаралды 56 М.
Starting a Career in Data Science (10 Thing I Wish I Knew…)
10:42
Sundas Khalid
Рет қаралды 175 М.
Data Analyst Job Interview - Don't make these 7 mistakes
11:02
How I'd Learn Data Analytics in 2024 (If I Had to Start Over)
14:08
CareerFoundry
Рет қаралды 796 М.
when foldable cellphones follow the trend#shorts
0:11
amazing populer
Рет қаралды 12 МЛН
ПС 110/10. Кто то подключил "левак" 110000 вольт!?
0:34
Советы электрика
Рет қаралды 1 МЛН