LeetCode Medium 2308 'Arrange Table by Gender' Interview SQL Question with Detailed Explanation

preview_player
Показать описание

In this video I solve and explain a medium difficulty 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
Рекомендации по теме
Комментарии
Автор

Superb explanation brother. Keep it up.

mukundkvyas
Автор

very well explained brother. I had figured out using the rank and order by ranks, but the final execution was missing. Got it now.

nitinmadan
Автор

with cte as
( select * , rank() over (partition by gender order by userid) as rk
case when gender = 'female' then 1 when gender = ' Other' then 2 else 3 as rk2 from genders
)
select userid, gender from cte where rk=1 order by rk2
union all
select userid, gender from cte where rk=2 order by rk2
union all
select userid, gender from cte where rk=3 order by rk2

ujjwalvarshney
Автор

@everyday data science - gosh what a logic, are you sure, you don't have SQL engine built into your brain ?? you think like a Database system personified

sivasrimakurthi