LeetCode 1965 Interview SQL Question with Detailed Explanation | Practice SQL

preview_player
Показать описание
Previous Video: LeetCode 1890 Latest Login in 2020

In this video I solve and explain a leetcode SQL question using MySQL query. This question has been asked in Apple, Facebook, Amazon, Google, Adobe, Microsoft, Adobe interviews or what we popularly call FAANG interviews.
I explain the related concept as well. This question includes points to keep in mind to develop SQL queries.

LeetCode is the best platform to help you enhance your skills, expand your knowledge and prepare for technical interviews.

If you found this helpful, Like and Subscribe to the channel for more content.

#LeetCodeSQL #FAANG #SQLinterviewQuestions
Рекомендации по теме
Комментарии
Автор

--ALTERNATE
select coalesce(e.employee_id, s.employee_id) as employee_id
from Employees e full outer join
Salaries s on e.employee_id=s.employee_id
where e.name is null or s.salary is null
order by 1;
but remember MySQL does not support the FULL OUTER JOIN syntax directly.

anirbansatapathi
Автор

Why can't we do a full outer join here??

harshavardhanmadasi
Автор

I was trying to solve this question by using full outer join below is my query

select employees.employee_id, employees.name, salaries.salary
from employees full join salaries
on employees.employee_id =salaries.employee_id

But it is showing error: "Unknown column 'employees.employee_id' in 'field list'"

ajaykumargaudo
Автор

i was trying to solve without using join here is the solution,
select * from (select employee_id from Salaries
where employee_id not in (select employee_id from Employees)
union
select employee_id from Employees
where employee_id not in (select employee_id from Salaries)) as employee_id
order by employee_id ;

akshaypatil
Автор

--ALTERNATE

with cte1 as (
select employee_id
from Employees
union
select employee_id
from Salaries
),
cte2 as (
select i.employee_id, e.name
from cte1 i
left join Employees e on i.employee_id=e.employee_id
)
select c.employee_id
from cte2 c
left join Salaries s on c.employee_id=s.employee_id
where name is null or salary is null

hdr-tech
Автор

Can't we solve it like this

Select e.employee_id from Employee e left join salaries s on e.employee_id = s.employee_id where e.name is null or s.salary is null;

abhinavtiwari