Sir awasome... everyday i solve problems by taking help from your videos
@EverydayDataScience2 жыл бұрын
Keep it up, Deepanshu. Consistency is the key !
@ayushtyagi42402 жыл бұрын
select customer_number from Orders group by customer_number order by count(customer_number) desc limit 1 this is also one way
@AbhishekSingh-vl1dp Жыл бұрын
select customer_number from Orders group by customer_number order by count(order_number) desc limit 1 this is much simple
@mahaksingg3 ай бұрын
u r doing a great job thanks
@rayyanamir85602 жыл бұрын
with cte as ( select*,count(order_number) over (partition by customer_number) as count_of_order from orders ) ,cte2 as ( select*, dense_rank() over(order by count_of_order desc) as rank_of_orders from cte ) select customer_number from cte2 where rank_of_orders=1 limit 1
@luyaowang46066 ай бұрын
hhh, not sure if this one is faster
@abhisheksharma66172 ай бұрын
May not be the best approach, but works : select customer_number from orders group by customer_number having count(*) > 1 order by count(*) desc limit 1;
@mlvprasadofficial2 жыл бұрын
8TH ONE COMPLETED..TQ
@EverydayDataScience2 жыл бұрын
Awesome work, keep it up.
@RahulSharma-ht2xz Жыл бұрын
thank you so much sir
@pankajchandel1000 Жыл бұрын
with cte as (select count(order_number) as NumOdr from Orders group by customer_number) select customer_number from cte where NumOdr = (select max(NumOdr) from cte);
@RitzFootball2 жыл бұрын
Learned new concept of CTE, nicely explained, 1 doubt that is why are we mentioning FROM cte again in the end . u have already mentioned FROM cte in the 9th line.can u pls explain this. thank you.
@EverydayDataScience2 жыл бұрын
Okay, so you can't write WHERE NumOrd = MAX(NumOrd). You need to calculate the MAX of that column. So firstly the subquery, SELECT MAX(NumOrd) FROM cte executes and finds the maximum value. Then the cursor goes to outer part i.e. FROM cte it SELECTs customer_number and filters only those rows where NumOrd is equal to Maximum (WHERE NumOrd = the maximum value calculated from the subquery)
@pankajchandel1000 Жыл бұрын
select customer_number,count(order_number) from Orders group by customer_number having count(order_number)= select max(NumOdr) from(select count(order_number) as NumOdr from Orders group by customer_number )
@pranveshpandey631611 ай бұрын
Hi, can you please help with this query which i have written, it passes the testcase wnat to know if it is more efficient than yours? select t.customer_number from (select customer_number, count(customer_number) as countcc from Orders group by customer_number order by countcc desc limit 1) as t
@MyAnish229 ай бұрын
No semi colon required for cte queries?
@s.211 Жыл бұрын
select customer_number from orders group by customer_number having count(customer_number) >= all(select count(customer_number) from orders group by customer_number );
@TheEleetcoder Жыл бұрын
excellent!!
@EverydayDataScience Жыл бұрын
Glad that you found it useful.
@arunraj38665 ай бұрын
Select customer _number from Orders groupby customer_number Having Count(customer_number) >1 Will this work?
@hemanthtummala7532 жыл бұрын
instead we can use limit 0,1
@dynamickaushik25686 ай бұрын
The query in this video is correct. 👍 I tried other solution which is as follows SELECT MAX(customer_number) AS customer_number FROM Orders This query is accepted by Test Result. However, when I click the Submit button it shows Wrong answer. Later on I read the whole question again, then I found at the very end there is "Follow Up" information that also must be considered. So, that's why the query in this video is correct.
@anirbansarkar63062 жыл бұрын
with cte as( select customer_number, count(*) as total_orders from Orders group by customer_number ), cte2 as( select customer_number, dense_rank() over(order by total_orders desc) as ranku from cte ) select customer_number from cte2 where ranku=1