This was asked in my interview yesterday, I wish I had watched this earlier, but now I’m damn sure I won’t forget how to tackle these kind of problems ,thank you so much Ankit bhaiya 💯
I am preparing for interviews and I just came across your channel. The videos are really informative. Thankyou so much !! 👍🏻 Keep up the good work, buddy.
Great solutions in simple way. I would like to share my interview experience.. This was the 1st questions asked in OPTUM(UHG) interview.. both using SQL & Tableau .. @Ankit your videos are really very helpfull in clearing concepts & basics .. keep up the good work :)
Hello sir please let me know this will work or not with cte as(select *,row_number() over(partition by id) rnk from mode) select id from cte where rnk in (select max(rnk) from cte);
with cte as( select id, row_number() over (partition by id order by id) most_time from mode) select * from cte where most_time = (select max(most_time) from cte)
Excellent explanation bro! I think instead of 2 cte's we can use this code with cte as ( select *, rank() over(order by count(id) desc) as rnk from mode group by id ) select id from cte where rnk = 1;
This was asked in my interview yesterday, I wish I had watched this earlier, but now I’m damn sure I won’t forget how to tackle these kind of problems ,thank you so much Ankit bhaiya 💯
I am preparing for interviews and I just came across your channel. The videos are really informative. Thankyou so much !! 👍🏻
Keep up the good work, buddy.
Thank you 😊
Your videos are really helpful in preparation of SQL. I subscribed your channel to learn more and in detail about SQL.
Great solutions in simple way. I would like to share my interview experience.. This was the 1st questions asked in OPTUM(UHG) interview.. both using SQL & Tableau ..
@Ankit your videos are really very helpfull in clearing concepts & basics .. keep up the good work :)
Thank you 😊
For which role?
Thanks Brother for your precise explanation,though I had the knowledge about joins still I got some useful insights.
Hello sir please let me know this will work or not
with cte as(select *,row_number() over(partition by id) rnk from mode)
select id from cte where rnk in (select max(rnk) from cte);
with cte as(
select id, row_number() over (partition by id order by id) most_time from mode)
select * from cte where most_time =
(select max(most_time) from cte)
I'm thinking about using row_number() as well because there will only be only one record in output this way
Great explanation sir, I have also solved it but using subquery and rank function without CTE
Cool
Excellent explanation bro! I think instead of 2 cte's we can use this code
with cte as
(
select *,
rank() over(order by count(id) desc) as rnk
from mode
group by id
)
select id
from cte
where rnk = 1;
Great 👍
cte as (select id, rank() over (order by count(*) desc) rwn from mode group by id)
select * from cte where rwn =1
Much helpful! Thanks for putting it up
🙏
Can you please make videos on python and ML
Thanks... Great video
🙏
Good Ankit
Thank you 😊
Thanks
thank you
;WITH cte
AS (SELECT id,
RANK() OVER (ORDER BY COUNT(id) DESC) AS RNK
FROM dbo.mode
GROUP BY id)
SELECT id
FROM cte
WHERE RNK = 1;
SELECT TOP 1 WITH TIES *,COUNT(1) AS frequency FROM mode
GROUP BY id
ORDER BY COUNT(1) DESC;
Done
Here is my Code:
select top 1 id, count(*) as Frequency from mode
group by id order by count(*) desc
select top 1 id, count(*) as Frequency from mode
group by id
order by frequency desc
With you sql seems piece of cake
It is piece of cake if you understand fundamentals 😊
select id, count(id) as occurrences from modes group by id having count(id) = (select max(count(id)) from modes group by id)
How about this?
with cte as
(select id,count(*)as m from mode1 group by id order by M desc)
select id,M from cte where M=(select max(M) from cte)
nested aggergation not allowed
@@sz6618 what?
@@armanmardhani8963 max and count both are aggregate function. You can not use both function together in SQL. In BI tool it's possible