RANK, DENSE_RANK, ROW_NUMBER SQL Analytical Functions Simplified

Поділитися
Вставка
  • Опубліковано 29 січ 2025

КОМЕНТАРІ • 230

  • @jasleenkaur-cw2fw
    @jasleenkaur-cw2fw Рік тому +28

    Clear explanation 💯 For those asking for dataset:
    create table employee(
    emp_id int,
    emp_name varchar(20),
    dept_id int,
    salary int
    );
    insert into employee values(1,'Ankit',100,10000);
    insert into employee values(2,'Mohit',100,15000);
    insert into employee values(3,'Vikas',100,10000);
    insert into employee values(4,'Rohit',100,5000);
    insert into employee values(5,'Mudit',200,12000);
    insert into employee values(6,'Agam',200,12000);
    insert into employee values(7,'Sanjay',200,9000);
    insert into employee values(8,'Ashish',200,5000);

    • @shoaibraza5532
      @shoaibraza5532 11 місяців тому

      Thanks

    • @mohammadsaad7412
      @mohammadsaad7412 7 місяців тому +3

      u can insert using single insert query
      create table employee(
      emp_id int,
      emp_name varchar(20),
      dept_id int,
      salary int
      );
      INSERT INTO employee (emp_id, emp_name, dept_id, salary)
      VALUES (1, 'Ankit', 100, 10000),
      (2, 'Mohit', 100, 15000),
      (3, 'Vikas', 100, 10000),
      (4, 'Rohit', 100, 5000),
      (5, 'Mudit', 200, 12000),
      (6, 'Agam', 200, 12000),
      (7, 'Sanjay', 200, 9000),
      (8, 'Ashish', 200, 5000);

  • @sandeepreddykaduduri799
    @sandeepreddykaduduri799 Рік тому +5

    This Explanation Blew my mind..!!
    From Scaring.. To Caring..on SQL. its just because of u Guruji🙏🙏

  • @nagasp882
    @nagasp882 3 роки тому +7

    Very good explanation, short and concise. It's the only video i would want to watch before my interview for quick revision.

  • @niki2098
    @niki2098 Рік тому +1

    Very good explanation and easier to understand. Earlier I'm unable to understand difference between these 3 functions now I'm clear. Thank you so much for this video.

  • @sanchitavichale6737
    @sanchitavichale6737 Рік тому +1

    I didn't understand analytical function until I see this video.
    Thank you for explain in simple word to understand. 👍

  • @gauravpanchariya
    @gauravpanchariya 4 місяці тому

    Very aptly explained. I was asked this window sql question in Gainwell interview. I couldn't answer as I were not aware of it. I searched for these functions and saw your video. It is very easily explained and very precise to the core.

  • @srikantjena4532
    @srikantjena4532 2 роки тому +5

    Absolutely good to watch with simpler explanations :-)

  • @tirthshah8293
    @tirthshah8293 8 місяців тому

    Explained to the point. Cleared the doubt related to the difference between these all the functions.

  • @Maharanasunil01
    @Maharanasunil01 3 роки тому +11

    I was looking for videos on Advance SQL but was still struggling with understanding the concepts.
    I really liked the explanation. It's time to practice a few questions ;)
    Thank you, can't wait for the next video :)

  • @nirmalbisht9710
    @nirmalbisht9710 3 роки тому +1

    Enjoy very topic you taught sir .. You have amazing teaching skill even these hard topic you cover very easily thank U

  • @haripriyaramakrishnan6316
    @haripriyaramakrishnan6316 Рік тому

    All are amazing videos.Very clear experience. It is very useful to refresh the SQL before interview.I am working as AVP in citicorp.Thank you very much Recently I used ur amazing videos to clear interview. Thank you very much.

  • @abhisheknigam3768
    @abhisheknigam3768 4 місяці тому +1

    Amazing explanation.

  • @mohitupadhayay1439
    @mohitupadhayay1439 2 роки тому

    This is by far the best approach to teaching the windows function. SUBBED right away!

  • @sapnanimbalkar1210
    @sapnanimbalkar1210 Рік тому

    Enhancing clarity leads to an interest in learning. Thank you Ankit.. !

  • @nainarahangdale1261
    @nainarahangdale1261 2 роки тому

    That's the simplest and most understandable explanation :) Thank You !!

  • @pondarajagadeesh4987
    @pondarajagadeesh4987 Рік тому

    Very good explanation, short and concise

  • @sajidulahmed3354
    @sajidulahmed3354 Рік тому

    It's simple and easily understandable. I haven't even understood earlier from the top UA-camrs. Thanks for your efforts. Keep it up!

  • @Palak_ki_jhalak1
    @Palak_ki_jhalak1 2 роки тому

    Thank you so much for all your videos and explaining in simpler language.All videos are very helpful 😊

  • @BabyMeraLearn
    @BabyMeraLearn Рік тому

    Very nicely explained and in easy to understand. Great job!

  • @skillup638
    @skillup638 2 роки тому

    💎 videos glad I founded it on UA-cam

  • @shubhipayal4073
    @shubhipayal4073 Рік тому

    Thankyou .After lots of watching videos finally my concept is cleared here.

  • @akshaychoudhary5770
    @akshaychoudhary5770 3 роки тому +1

    neet work. nicely explianed. expecting more such videos. LIKED COMMMENTED & SUBSCRIBED.

  • @dataworksstudio
    @dataworksstudio 2 роки тому

    An absolute no-nonsense guide to window functions!
    Thanks bhaiyya ❤️

  • @anishdeshpande395
    @anishdeshpande395 Рік тому

    Understood teh concept in a very simple way. Thank you :)

  • @ujjwalkumari5690
    @ujjwalkumari5690 2 роки тому

    Great explained! looking forward for more videos

  • @arunabhaghoshal2381
    @arunabhaghoshal2381 2 роки тому

    Thanks very much for the clarity and in detailed explanation of the concepts !

  • @ssaaurabh456
    @ssaaurabh456 2 роки тому

    hatoff to big brother love from noida ................you cleared concept like piece of cake

  • @bhaveshrathod9898
    @bhaveshrathod9898 Рік тому +1

    Really very good explanation sir! Thank you very much:)

  • @MrAsgar123
    @MrAsgar123 Рік тому

    Thank you so much for your hard work. It's really very useful to understand the Analytical Functions.

  • @naveenkumarp9874
    @naveenkumarp9874 2 роки тому

    🥰my doubt is cleared Excellent Explaination about ranks thanks a lot👍

  • @mohit231
    @mohit231 3 роки тому +1

    Great video

  • @manojahlawat2881
    @manojahlawat2881 10 місяців тому

    short and good explanation in this video

  • @karangoyal3747
    @karangoyal3747 2 роки тому

    Thanks. please continue the good work.

  • @SHUBHADIP1
    @SHUBHADIP1 2 роки тому

    Thank you Ankit ! it was a very simple and clear explanation.

  • @RiffswithMohit
    @RiffswithMohit 2 роки тому

    bhai thanks bht sahi and ez way me samjhaya apne

  • @ektakumari4496
    @ektakumari4496 2 роки тому

    Hats off to your content👌👌

  • @tapangshu
    @tapangshu 2 роки тому

    Such a simple explanation to these 3 functions. Thanks Ankit :)

  • @minute_syntax
    @minute_syntax 2 роки тому +1

    great video

  • @rasikamahadeshwar8097
    @rasikamahadeshwar8097 6 місяців тому

    Very good explanation.

  • @Akshay12511
    @Akshay12511 2 місяці тому

    Thankz ankit best explaination

  • @sakshitangri7600
    @sakshitangri7600 2 роки тому

    Simply amazing. Thank you so much

  • @meghagupta8664
    @meghagupta8664 Рік тому

    It's very helpful Sir thank you please make more this types of vedio 😊

  • @aakrititimilsina7662
    @aakrititimilsina7662 Рік тому +1

    Very nicely explained!

  • @suman3316
    @suman3316 3 роки тому +1

    apka...pehla subcriber hoo main.....bhaiya ...please bring lots of practical videos used in real time

  • @hammadahmed1659
    @hammadahmed1659 3 роки тому +1

    Thanks Sir, very nicely explained..

  • @kaafi_alsi
    @kaafi_alsi 3 дні тому

    Crisp and easy explanation Ankit bhaiya🫡

  • @sushantdalela7350
    @sushantdalela7350 8 місяців тому

    Good work bro well explained

  • @nabiltahwildar7931
    @nabiltahwildar7931 Рік тому

    Thank You Sir, Clear understood✌👌

  • @arunsinghkachhwaha8286
    @arunsinghkachhwaha8286 Рік тому

    Great Learning with you Ankit😊

  • @AttitudeAdjestment
    @AttitudeAdjestment 5 місяців тому +1

    Nice video!

  • @gayatrikumbhare8530
    @gayatrikumbhare8530 10 місяців тому

    well explained 💯💯

  • @annasagaramgurumahendrarao6285
    @annasagaramgurumahendrarao6285 3 роки тому +1

    U explained very well

  • @aish7711
    @aish7711 3 роки тому

    Clear explanation. waiting for next video

  • @kneelakanta8137
    @kneelakanta8137 2 роки тому

    Same question asked in my yesterday interview 👍👍

  • @gopavarambavithra3025
    @gopavarambavithra3025 6 місяців тому

    Nicely explanation

  • @skrandomthings4474
    @skrandomthings4474 5 місяців тому

    Informative

  • @ashishkumarg5
    @ashishkumarg5 2 роки тому

    Nice explanation

  • @kingsleyelijah8461
    @kingsleyelijah8461 2 роки тому +2

    create table emp(
    emp_id int,
    emp_name varchar(20),
    department_id int,
    salary int
    );
    insert into employee values(1,'Ankit',100,10000);
    insert into employee values(2,'Mohit',100,15000);
    insert into employee values(3,'Vikas',100,10000);
    insert into employee values(4,'Rohit',100,5000);
    insert into employee values(5,'Mudit',200,12000);
    insert into employee values(6,'Agam',200,12000);
    insert into employee values(7,'Sanjay',200,9000);
    insert into employee values(8,'Ashish',200,5000);

    • @dishantahuja975
      @dishantahuja975 2 роки тому

      Thanks for create statement.

    • @sriphani4720
      @sriphani4720 2 роки тому

      Please pin this comment so that someone who views this video can practice the same while learning. Thank you.

  • @yuktiagrawal8606
    @yuktiagrawal8606 2 роки тому

    This is superb... I recently came across to your channel and it is really helpful😊
    Teacher's should teach like you..

  • @arunjadad
    @arunjadad 9 місяців тому

    Well explained sir

  • @jyothieswari2561
    @jyothieswari2561 Рік тому

    Great explanation sir....tq

  • @IndianHacker-hisBest
    @IndianHacker-hisBest Рік тому

    Very nice explanation

  • @proandy4448
    @proandy4448 7 місяців тому +1

    Please can you maintain the English language only. Your content is very helpful & i think it will not benefit the larger audience if you speak any other language. You are a great teacher!!

    • @ankitbansal6
      @ankitbansal6  7 місяців тому

      This is the only video in Hindi on my UA-cam channel

  • @adityasahu8626
    @adityasahu8626 2 роки тому

    very good explanation 😊

  • @priyatiwari234
    @priyatiwari234 5 місяців тому

    clear explanation

  • @vishnujatav6329
    @vishnujatav6329 Рік тому

    Really helpful

  • @RoopmathiGunnaubcmba
    @RoopmathiGunnaubcmba Рік тому +1

    Thank you Ankit this was very easy to understand. Can you post some more interview questions using RANK(), DENSE RANK() and ROW_number

    • @ankitbansal6
      @ankitbansal6  Рік тому

      There are many in my complex SQL problems playlist

  • @samthomas7686
    @samthomas7686 2 роки тому

    Great explanation Ankit. Keep on creating similar stuff, all the best!

  • @noopurkumari6418
    @noopurkumari6418 2 роки тому +1

    Very nice videos. It cleared my concept around these functions. Thank you. Please let me know online where i can practise SQL queries.

    • @ankitbansal6
      @ankitbansal6  2 роки тому

      Thank you. You can practice on the DataLemur website.

  • @AT-dn6gd
    @AT-dn6gd 2 роки тому

    JUST WOW

  • @rohitrai4811
    @rohitrai4811 Рік тому

    Appreciated bro 👍

  • @niyatishah9020
    @niyatishah9020 Рік тому

    I found the entire video to be well explained. There is just one thing I need to understand
    How did you know you had to use aliasing at 8:55?

  • @veereshsaliyan6007
    @veereshsaliyan6007 Рік тому +1

    Thanks alot sir✨

  • @harshavardhanraj3028
    @harshavardhanraj3028 Рік тому

    great explanation and the best thing here is using small dataset to simplify concepts in a short span
    please help me why alias was added at the last to get output i want to visualize how it works.

    • @ankitbansal6
      @ankitbansal6  Рік тому

      In SQL server it is mandatory to give alias to a sub query

  • @shashikiran6859
    @shashikiran6859 2 роки тому

    Great Explanation

  • @Ashis_Kumar90
    @Ashis_Kumar90 Рік тому

    Clear and Crisp

  • @rahulyeole6411
    @rahulyeole6411 2 роки тому

    Nice video sir please upload more videos with interview questions

  • @samarjitmechie
    @samarjitmechie Рік тому +2

    Sir, @8:50 you got an error and then you fixed it with an alias. Could you please let me know why we need an alias(a) there?? I am a beginner and a little confused.. Please help!

    • @ankitbansal6
      @ankitbansal6  Рік тому

      In SQL server you need to give alias to sub query

    • @samarjitmechie
      @samarjitmechie Рік тому +1

      @@ankitbansal6 oh, I use MySQL, so I don't need to put alias, right?

    • @masoodahmed6600
      @masoodahmed6600 Рік тому

      ​@@samarjitmechie Alias is mandatory we have to give in mysql also

  • @anguraj1401
    @anguraj1401 Рік тому

    Thanks Ankit

  • @psh57
    @psh57 3 місяці тому

    THANK YOU MENAS A LOT

  • @blackjack4667
    @blackjack4667 2 роки тому

    Thanks Bhaiya

  • @rishinagar199
    @rishinagar199 Рік тому +1

    Bro ye where clause vala kesey kiya ....mujmey to error show kr raha hai ki 'rnk unknown column in where clause

  • @LogicQuest
    @LogicQuest 2 роки тому +1

    Thanks for these..keep uploading and simplifying these concepts..
    I hope to see some python,tableau content soon too..
    Hope your channel reaches 100k fast..best wishes ..

    • @ankitbansal6
      @ankitbansal6  2 роки тому +1

      Thank you so much 😊 I will start Tableau soon. I am thinking should I start with basic tutorials or direct scenario based questions just like SQL. Any suggestions?

    • @idhwanibhatt
      @idhwanibhatt 2 роки тому +6

      @@ankitbansal6 No no start with direct scenario based questions / case study. We are fed with Tutorials.

  • @DataRevolution10
    @DataRevolution10 2 роки тому

    Nice video.

  • @zohebakber5056
    @zohebakber5056 2 роки тому

    nicely explained, bro

  • @parteekranga3238
    @parteekranga3238 2 роки тому

    All I want to say is, I LOVE YOU MAN

  • @amchourasia
    @amchourasia Рік тому

    Thanks for the video!

  • @sureshdarla5540
    @sureshdarla5540 9 місяців тому +1

    thanks for lecture, according to the last example , RANK( ) can't solve for the second highest salary provided by the department . am I right?

  • @simranjeetsingh4101
    @simranjeetsingh4101 Рік тому

    Thanku ♥️

  • @ArtistJatinRana
    @ArtistJatinRana Рік тому

    Thankyou sir

  • @varunl6948
    @varunl6948 Рік тому

    Thanks for this!

  • @sreevidyagireesh
    @sreevidyagireesh Рік тому +1

    Nice explanation.. I have a doubt performance wise rank or dense rank is better

  • @nehaarora8754
    @nehaarora8754 3 роки тому

    Good one Baba ji :)

  • @romideep4463
    @romideep4463 2 роки тому +2

    To get highest salary..i gues you should use dense_rank. Because we need 3rd highest salary we can't fetch from this example which you have given...Am I right???

    • @kraminkaverma7837.
      @kraminkaverma7837. 2 роки тому

      Yes, for getting highest salary we should use dense_rank.

  • @shwethaa937
    @shwethaa937 2 роки тому +1

    wanted to know if the records need to be sorted? or the partition function itself will take care of it ?

    • @ankitbansal6
      @ankitbansal6  2 роки тому

      Order by will take care of sorting

  • @PraveenSingh-no09ol
    @PraveenSingh-no09ol 3 роки тому +2

    Hi Ankit Bhai, if possible kindly create a video playlist on SQL how much it is required for Analytics domain.

  • @surojeetghosh8389
    @surojeetghosh8389 2 роки тому

    hello sir,i almost watch all of your videos and your videos have always given me useful insights.i'm an aspiring data analyst.i know the basic concepts of sql.i just want to know how to go on that next level where i can crack interviews with big companies.thank you

    • @ankitbansal6
      @ankitbansal6  2 роки тому

      Just solve my complex SQL playlist yourself

  • @ankush_in_sync5998
    @ankush_in_sync5998 7 місяців тому

    Thank You.

  • @roopasp1860
    @roopasp1860 2 роки тому +1

    Thanks Ankit, can you please let me know how we will decide when to use rank(), dense_rank() and row_number()

    • @ankitbansal6
      @ankitbansal6  2 роки тому

      It depends on business use case. There is no thumb rule as such.

    • @roopasp1860
      @roopasp1860 2 роки тому

      @@ankitbansal6 thankyou

  • @veerjisingh6401
    @veerjisingh6401 2 роки тому +1

    Thanks for explaining in such simple language . I have one doubt regarding the interview question can that be solved by simply using GROUP BY department with max(salary)

    • @ankitbansal6
      @ankitbansal6  2 роки тому +1

      In that case you will get just max salary for each department but not other columns in the output

    • @ritikasood433
      @ritikasood433 2 роки тому

      @@ankitbansal6 : Can we use this query to get the highest salary from each department and display all columns, sub-query might not be best option/optimized way, please take a look and advice.
      select emp_id, emp_name, department_id , salary from employee where salary in
      (select max(salary) from employee group by department_id )