SQL Interview Question | 30 |#dataengineering |#dataanalyst |#powerbi | #sql #dataengineer
Akash Solkar
0:00 / 0:00
SQL Interview Question | 30 |#dataengineering |#dataanalyst |#powerbi | #sql #dataengineer
89 просмотров · 4 недели назад
Akash Solkar
138 подписчиков
89 просмотров · 4 недели назад
SQL Interview Question #30 | SQL JOINs
Can you correctly calculate the number of rows returned by different SQL JOINs when the tables contain duplicate IDs and NULL values?
In this SQL interview question, we work with two simple tables — Employee and Product — and determine the result of different JOIN operations.
In this video, we cover:
INNER JOIN row count
LEFT OUTER JOIN row count
RIGHT JOIN row count
How duplicate values affect JOIN results
How NULL values behave in SQL JOINs
A simple approach to solving SQL JOIN interview questions
Scripts;
-- Create the employees table
CREATE TABLE emp_tbl (
id INT,
emp_name VARCHAR(50)
);
-- Insert 4 rows with the requested IDs (1, 0, NULL, 1)
INSERT INTO emp_tbl (id, emp_name) VALUES
(1, 'Alice'),
(0, 'Bob'),
(NULL, 'Charlie'),
(1, 'Diana')
-- Create the product table
CREATE TABLE c (
id INT,
product_name VARCHAR(50)
);
truncate table product
-- Insert 4 rows with data
INSERT INTO product (id, product_name) VALUES
(0, 'Laptop'),
(NULL, 'Wireless Mouse'),
(1, 'Mechanical Keyboard'),
(1, 'Monitor');
This is a great SQL interview problem for Data Engineers, Data Analysts, BI Developers, and SQL Developers preparing for technical interviews.
💡 Interview Tip:
Don't just count the matching IDs. When a value appears multiple times, one row from one table can match multiple rows from the other table. Always think about the actual row combinations produced by the JOIN.
Try solving the question yourself before watching the explanation!
If you found this question useful, Like 👍, Subscribe, and follow for more SQL interview questions and Data Engineering concepts.
Topics covered
SQL JOINs | INNER JOIN | LEFT JOIN | RIGHT JOIN | NULL values | Duplicate rows | SQL Interview Questions | Data Engineering | Data Analytics | Power BI
#sql #sqlinterview #dataengineering #dataanalyst #dataengineer #powerbi #sqljoins #sqlquestions #dataanalytics #interviewquestions #viral #viralvideo #datascience #database #youtube #databricks #apachespark #pyspark #python