No video

LeetCode Medium 2084 Interview SQL Question with Detailed Explanation | Practice SQL

  Рет қаралды 5,259

Everyday Data Science

Everyday Data Science

2 жыл бұрын

Question: leetcode.com/p...
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

Пікірлер: 28
@metricsview33
@metricsview33 7 ай бұрын
with cte as (select order_id, customer_id, order_type, sum(order_type) over(partition by customer_id) as r_sum, min(order_type) over(partition by customer_id) as r_min from Orders) select order_id, customer_id, order_type from cte where r_sum in(0,2) or order_type=r_min
@florincopaci6821
@florincopaci6821 2 жыл бұрын
Your videos are very useful! Thank you and if is possible please do in the future a video about 2153 question in the LeetCode. Please Other 2 solutions at this question- SELECT order_id, customer_id, order_type FROM Orders WHERE order_type = 0 OR (order_type = 1 AND customer_id NOT IN (SELECT customer_id FROM Orders WHERE order_type = 0)); SELECT order_id, customer_id, order_type FROM (SELECT a.*, RANK() OVER(PARTITION BY customer_id ORDER BY order_type) AS rk FROM Orders a) t WHERE rk = 1
@EverydayDataScience
@EverydayDataScience 2 жыл бұрын
Sure, @florin. Great thought process on the alternative solutions.
@florincopaci6821
@florincopaci6821 2 жыл бұрын
@@EverydayDataScience Thank you and please regarding that question because is give me headache. Thank you ! All the best!
@Bhaweshgupta
@Bhaweshgupta 4 ай бұрын
with cet ( select *,first_value(order_type) over(partition by customer_id order by order_type) fvl from Orders ) select order_id,customer_id,order_type from cet where order_type=fvl
@haleinan2727
@haleinan2727 2 жыл бұрын
Thanks a bunch with the detailed explanation, much appreciated!! Really helpful, and clear!
@EverydayDataScience
@EverydayDataScience 2 жыл бұрын
Glad that you found the video useful, Hale.
@ritusantra8641
@ritusantra8641 Ай бұрын
with cte as (select *, rank() over(partition by customer_id order by order_type) as rnk from orders) select order_id, customer_id, order_type from cte where rnk = 1 order by order_type desc; with cte as (select *, min(order_type) over(partition by customer_id) as rnk from orders) select order_id, customer_id, order_type from cte where order_type = rnk order by order_type desc;
@MrTrendCatcher
@MrTrendCatcher 2 ай бұрын
One of the solutions: SELECT * FROM Orders WHERE (customer_id, order_type) IN (SELECT customer_id, MIN(order_type) FROM Orders GROUP BY customer_id);
@roymou5856
@roymou5856 5 ай бұрын
WITH CTE AS ( select order_id, customer_id, order_type , min(order_type) over(partition by customer_id) as min_order from Orders ) SELECT order_id, customer_id, order_type FROM CTE where order_type + min_order in (0,2)
@sivasrimakurthi206
@sivasrimakurthi206 Жыл бұрын
@everyday Data Science, very nice explanation, these are the tricks everyone needs to understand to be a successful Data scientist/Analyst. The way you explained is easy to understand and because it is visual it gets more easy. Thanks a lot for time and kindness.
@EverydayDataScience
@EverydayDataScience Жыл бұрын
Thanks for such kind words 😊 Glad that the video was useful. All the best.
@ujjwalvarshney3188
@ujjwalvarshney3188 Жыл бұрын
create temp table Orders1 (select * , min(order_type)over(partition by customer_id) as mn from orders) select orders,customer_id,order_type*mn as order_type from Orders1;
@expandingourselves
@expandingourselves Жыл бұрын
Alternative solution : with cte as ( select distinct(order_id) from orders where customer_id in ( select distinct(customer_id ) from orders where order_type = 0) and order_type 1 union select distinct(order_id) from orders where customer_id not in ( select distinct(customer_id ) from orders where order_type = 0) ) select * from Orders where order_id IN ( select order_id from cte )
@anujkumar8341
@anujkumar8341 2 жыл бұрын
correct me if i'm wrong , we can solve this problem with dense rank function
@AbhijeetSachdev
@AbhijeetSachdev 3 ай бұрын
Is it the right solution: SELECT customer_id FROM orders WHERE customer_id NOT IN ( SELECT customer_id FROM orders WHERE order_type = 1 AND customer_id IN ( SELECT customer_id FROM orders WHERE order_type = 0 ) );
@rayyanamir8560
@rayyanamir8560 2 жыл бұрын
Please upload more medium questions sir.
@EverydayDataScience
@EverydayDataScience 2 жыл бұрын
Sure, Rayyan.
@ShivamGupta-cx3hy
@ShivamGupta-cx3hy 2 жыл бұрын
Hello Sir , I really like your videos but I have a doubt ,are these questions available for.free on leetcode or are they in premium version
@EverydayDataScience
@EverydayDataScience 2 жыл бұрын
Glad that you like it, Shivam. These questions are in the premium version of Leetcode.
@mlvprasadofficial
@mlvprasadofficial 2 жыл бұрын
45
@ShivamGupta-cx3hy
@ShivamGupta-cx3hy 2 жыл бұрын
Also can I talk to you sir ,I have many questions in my mind about how to prepare for data science.
@EverydayDataScience
@EverydayDataScience 2 жыл бұрын
Sure, you can either comment down here or send an email at everydaydatasciencechannel@gmail.com
@marispano
@marispano 2 жыл бұрын
where order_type=min_order_type
@EverydayDataScience
@EverydayDataScience 2 жыл бұрын
Brilliant catch, Marjia. That’s a great way to solve this question as well 👍😊
@gunjanpatil8191
@gunjanpatil8191 2 жыл бұрын
I was going to write this also. Good answer. Thanks for video and help
LeetCode Medium 2112 Interview SQL Question with Detailed Explanation
10:28
Everyday Data Science
Рет қаралды 1,2 М.
LeetCode Medium 1709 Interview SQL Question with Detailed Explanation
12:54
Everyday Data Science
Рет қаралды 1,7 М.
Comfortable 🤣 #comedy #funny
00:34
Micky Makeover
Рет қаралды 16 МЛН
Little brothers couldn't stay calm when they noticed a bin lorry #shorts
00:32
Fabiosa Best Lifehacks
Рет қаралды 18 МЛН
Jumping off balcony pulls her tooth! 🫣🦷
01:00
Justin Flom
Рет қаралды 35 МЛН
LeetCode Medium 1398 Amazon Interview SQL Question with Detailed Explanation
13:56
Database Indexing for Dumb Developers
15:59
Laith Academy
Рет қаралды 51 М.
LeetCode Medium 1596 Amazon Interview SQL Question with Detailed Explanation
16:38
SQL Interview Problem asked during Amazon Interview
15:15
techTFQ
Рет қаралды 22 М.
I've been using Redis wrong this whole time...
20:53
Dreams of Code
Рет қаралды 352 М.
LeetCode 1795 Interview SQL Question with Detailed Explanation | Practice SQL
12:05
LeetCode Medium 1934 Interview SQL Question with Detailed Explanation
11:47
Everyday Data Science
Рет қаралды 6 М.
Comfortable 🤣 #comedy #funny
00:34
Micky Makeover
Рет қаралды 16 МЛН