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

  Рет қаралды 1,689

The Big Data Show

The Big Data Show

Ай бұрын

Пікірлер: 7
@santypanda4903
@santypanda4903 Ай бұрын
Is this the full video? Where is the link? I thought it got abruptly cut at the end.
@vabz_parab
@vabz_parab Ай бұрын
Record count for 'NULL' in case of LEFT JOIN should be 2. Not 4 (Wrong output shown in the last)
@TheBigDataShow
@TheBigDataShow Ай бұрын
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 Ай бұрын
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 Ай бұрын
@vabz_parab thank you for correction
@vabz_parab
@vabz_parab Ай бұрын
@@TheBigDataShow thanks and welcome!! And I liked your 1st query approach too. Seems interesting 👍🏻
@Someonner
@Someonner Ай бұрын
AMEX also asks the same question
SQL Portfolio Project | Data Analytics | Danny's Diner SQL Challenge
1:18:13
DAY - 1 | MLOps Foundations and Fundamentals
2:00:06
iNeuron Intelligence
Рет қаралды 26 М.
THE POLICE TAKES ME! feat @PANDAGIRLOFFICIAL #shorts
00:31
PANDA BOI
Рет қаралды 25 МЛН
DEFINITELY NOT HAPPENING ON MY WATCH! 😒
00:12
Laro Benz
Рет қаралды 47 МЛН
Русалка
01:00
История одного вокалиста
Рет қаралды 5 МЛН
ОСКАР ИСПОРТИЛ ДЖОНИ ЖИЗНЬ 😢 @lenta_com
01:01
Repartition vs. Coalesce in Apache Spark | PySpark interview questions
19:22
Why I Quit the Scrum Alliance
7:58
The Passionate Programmer
Рет қаралды 11 М.
PWC Data Analyst Interview | SQL Intermediate Question 11
9:46
A Love For Life - Raja Rani - Piano Cover
0:45
Adithyha Jayakumar
Рет қаралды 128 М.
How can I fix my watery whipped cream?
3:48
Health·WHYS
Рет қаралды 11 М.
Unlocking Apache Kafka: The Secret Sauce of Event Streaming
17:17
The Big Data Show
Рет қаралды 672
PART 52 || DIY Wireless Switch forElectronic Lights - Easy Guide!
1:01
HUBAB__OFFICIAL
Рет қаралды 45 МЛН
Опыт использования Мини ПК от TECNO
1:00
Андронет
Рет қаралды 783 М.
Как распознать поддельный iPhone
0:44
PEREKUPILO
Рет қаралды 1,5 МЛН
После ввода кода - протирайте панель
0:18
Up Your Brains
Рет қаралды 1,2 МЛН