RANK, DENSE_RANK, ROW_NUMBER SQL Analytical Functions Simplified

Поделиться
HTML-код
  • Опубликовано: 16 окт 2024
  • In this video we will understand very important concept of SQL analytical functions RANK, DENSE_RANK, ROW_NUMBER.

Комментарии • 224

  • @jasleenkaur-cw2fw
    @jasleenkaur-cw2fw Год назад +21

    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 8 месяцев назад

      Thanks

    • @mohammadsaad7412
      @mohammadsaad7412 3 месяца назад +2

      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 Год назад +4

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

  • @nagasp882
    @nagasp882 2 года назад +7

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

  • @Maharanasunil01
    @Maharanasunil01 2 года назад +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 :)

  • @gauravpanchariya
    @gauravpanchariya 20 дней назад

    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.

  • @niki2098
    @niki2098 11 месяцев назад +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.

  • @srikantjena4532
    @srikantjena4532 2 года назад +5

    Absolutely good to watch with simpler explanations :-)

  • @sanchitavichale6737
    @sanchitavichale6737 Год назад +1

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

  • @akshaychoudhary5770
    @akshaychoudhary5770 2 года назад +1

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

  • @tirthshah8293
    @tirthshah8293 4 месяца назад

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

  • @nirmalbisht9710
    @nirmalbisht9710 2 года назад +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.

  • @sapnanimbalkar1210
    @sapnanimbalkar1210 Год назад

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

  • @mohitupadhayay1439
    @mohitupadhayay1439 2 года назад

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

  • @sajidulahmed3354
    @sajidulahmed3354 10 месяцев назад

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

  • @shubhipayal4073
    @shubhipayal4073 Год назад

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

  • @anishdeshpande395
    @anishdeshpande395 Год назад

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

  • @rishinagar199
    @rishinagar199 Год назад +1

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

  • @dataworksstudio
    @dataworksstudio 2 года назад

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

  • @nainarahangdale1261
    @nainarahangdale1261 Год назад

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

  • @ssaaurabh456
    @ssaaurabh456 Год назад

    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:)

  • @BabyMeraLearn
    @BabyMeraLearn 11 месяцев назад

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

  • @MrAsgar123
    @MrAsgar123 Год назад

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

  • @suman3316
    @suman3316 2 года назад +1

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

  • @skillup638
    @skillup638 Год назад

    💎 videos glad I founded it on RUclips

  • @sureshdarla5540
    @sureshdarla5540 6 месяцев назад +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?

  • @arunabhaghoshal2381
    @arunabhaghoshal2381 2 года назад

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

  • @pondarajagadeesh4987
    @pondarajagadeesh4987 Год назад

    Very good explanation, short and concise

  • @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 😊

  • @abhisheknigam3768
    @abhisheknigam3768 Месяц назад

    Amazing explanation.

  • @rasikamahadeshwar8097
    @rasikamahadeshwar8097 3 месяца назад

    Very good explanation.

  • @sarojsahoo8763
    @sarojsahoo8763 Год назад +1

    Nice explanation

  • @samthomas7686
    @samthomas7686 2 года назад

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

  • @manojahlawat2881
    @manojahlawat2881 7 месяцев назад

    short and good explanation in this video

  • @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

  • @RiffswithMohit
    @RiffswithMohit 2 года назад

    bhai thanks bht sahi and ez way me samjhaya apne

  • @noopurkumari6418
    @noopurkumari6418 Год назад +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  Год назад

      Thank you. You can practice on the DataLemur website.

  • @aakrititimilsina7662
    @aakrititimilsina7662 10 месяцев назад +1

    Very nicely explained!

  • @meghagupta8664
    @meghagupta8664 Год назад

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

  • @sushantdalela7350
    @sushantdalela7350 5 месяцев назад

    Good work bro well explained

  • @SHUBHADIP1
    @SHUBHADIP1 Год назад

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

  • @AttitudeAdjestment
    @AttitudeAdjestment 2 месяца назад +1

    Nice video!

  • @naveenkumarp9874
    @naveenkumarp9874 2 года назад

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

  • @niyatishah9020
    @niyatishah9020 8 месяцев назад

    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?

  • @tapangshu
    @tapangshu Год назад

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

  • @mohit231
    @mohit231 2 года назад +1

    Great video

  • @ujjwalkumari5690
    @ujjwalkumari5690 2 года назад

    Great explained! looking forward for more videos

  • @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.

  • @minute_syntax
    @minute_syntax 2 года назад +1

    great video

  • @karangoyal3747
    @karangoyal3747 2 года назад

    Thanks. please continue the good work.

  • @arunsinghkachhwaha8286
    @arunsinghkachhwaha8286 Год назад

    Great Learning with you Ankit😊

  • @PraveenSingh-no09ol
    @PraveenSingh-no09ol 2 года назад +2

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

  • @yuktiagrawal8606
    @yuktiagrawal8606 2 года назад

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

  • @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.

  • @hammadahmed1659
    @hammadahmed1659 2 года назад +1

    Thanks Sir, very nicely explained..

  • @sreevidyagireesh
    @sreevidyagireesh Год назад +1

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

  • @proandy4448
    @proandy4448 3 месяца назад +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  3 месяца назад

      This is the only video in Hindi on my RUclips channel

  • @gopavarambavithra3025
    @gopavarambavithra3025 3 месяца назад

    Nicely explanation

  • @nabiltahwildar7931
    @nabiltahwildar7931 Год назад

    Thank You Sir, Clear understood✌👌

  • @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

  • @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

  • @priyatiwari234
    @priyatiwari234 2 месяца назад

    clear explanation

  • @ektakumari4496
    @ektakumari4496 2 года назад

    Hats off to your content👌👌

  • @tarunaggarwal4995
    @tarunaggarwal4995 8 месяцев назад

    Nice explanation sir but i have small doubts if we have 2 conditions like salary and joining date and i want look at the salary but if some employees salary equal then he will look joining date and salary both so how we can find the data can you explain 😛

  • @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

  • @sakshitangri7600
    @sakshitangri7600 2 года назад

    Simply amazing. Thank you so much

  • @sandeepmohanty6088
    @sandeepmohanty6088 2 года назад

    Can we use row_number() in this case as row number will be unique and we can select where rownumber=1.

  • @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

  • @arunjadad
    @arunjadad 6 месяцев назад

    Well explained sir

  • @HEALSTATION-k6h
    @HEALSTATION-k6h 2 месяца назад

    Sir why did you use "From" two times at last query of the video jaha Department wise highest salary show karni hai .."From ( "
    And fir last mein bhi "From Emp" ? Even alias a toh kahi aaya hi nahi table mein ..please explain sir

  • @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 Год назад

      @@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 )

  • @gayatrikumbhare8530
    @gayatrikumbhare8530 6 месяцев назад

    well explained 💯💯

  • @kneelakanta8137
    @kneelakanta8137 Год назад

    Same question asked in my yesterday interview 👍👍

  • @jyothieswari2561
    @jyothieswari2561 9 месяцев назад

    Great explanation sir....tq

  • @rahulyeole6411
    @rahulyeole6411 2 года назад

    Nice video sir please upload more videos with interview questions

  • @skrandomthings4474
    @skrandomthings4474 2 месяца назад

    Informative

  • @aish7711
    @aish7711 2 года назад

    Clear explanation. waiting for next video

  • @mrinalmishra1437
    @mrinalmishra1437 2 года назад +1

    In MySQL also all these queries and concepts are same ?? Or it's slightly different ?

  • @divyadubey6679
    @divyadubey6679 16 дней назад

    Thank u so much for this video.
    Please share me link for query using pivot in mysql

  • @annasagaramgurumahendrarao6285
    @annasagaramgurumahendrarao6285 2 года назад +1

    U explained very well

  • @vishnujatav6329
    @vishnujatav6329 Год назад

    Really helpful

  • @amchourasia
    @amchourasia Год назад

    Thanks for the video!

  • @sunnymishra0389
    @sunnymishra0389 2 года назад +1

    Can you share the Amazon link to the mike you used? Also what software you used for Screen recording, voice recording and Video editing?

    • @ankitbansal6
      @ankitbansal6  2 года назад

      I use chrome extension for screen and voice recording.

    • @ankitbansal6
      @ankitbansal6  2 года назад

      So far not editing videos.

    • @sunnymishra0389
      @sunnymishra0389 2 года назад

      @@ankitbansal6 thanks man. Could you be more specific? Which Crome extension and Which mike you use?

    • @ankitbansal6
      @ankitbansal6  2 года назад +1

      Extension name is screen recorder and I use laptop microphone only.

  • @parteekranga3238
    @parteekranga3238 Год назад

    All I want to say is, I LOVE YOU MAN

  • @surojeetghosh8389
    @surojeetghosh8389 Год назад

    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  Год назад

      Just solve my complex SQL playlist yourself

  • @adityasahu8626
    @adityasahu8626 Год назад

    very good explanation 😊

  • @veereshsaliyan6007
    @veereshsaliyan6007 Год назад +1

    Thanks alot sir✨

  • @rohitrai4811
    @rohitrai4811 Год назад

    Appreciated bro 👍

  • @AbhishekGupta-ij3pn
    @AbhishekGupta-ij3pn Год назад

    Good morning Sir where we can practice online SQL ?

  • @052riyasingh8
    @052riyasingh8 Год назад

    Sir, instead of using 'PARTITION BY' clause inside the rank statement, can't we use 'GROUP BY' department_id in the end of the query, in order to get the ranks as per salaries of the departments ?

    • @ankitbansal6
      @ankitbansal6  Год назад

      Group by doesn't give rank

    • @052riyasingh8
      @052riyasingh8 Год назад

      @@ankitbansal6 ok thankyou for responding sir

    • @shristisrivastava1324
      @shristisrivastava1324 8 месяцев назад

      @@ankitbansal6 SIR WHEN WE WILL USE PARTITION BY AND WHEN WE WILL USE GROUP BY IN RANK,DENSE RANK AND IN ROW_NUMBER. I AM CONFUSED PLEASE REPLY ME

  • @IndianHacker-hisBest
    @IndianHacker-hisBest Год назад

    Very nice explanation

  • @AT-dn6gd
    @AT-dn6gd Год назад

    JUST WOW

  • @jaydeeppatidar4189
    @jaydeeppatidar4189 2 года назад

    Hi Sir, could you please let us know how much nosql/mongodb we should know to get placed in product based companies. Thank you in advance.

  • @SunilKumar_67
    @SunilKumar_67 4 месяца назад

    Ankit, there are people who may not understand Hindi, for them can you create a same video in English completely. Thank you

    • @ankitbansal6
      @ankitbansal6  4 месяца назад +1

      This is the only video in Hindi on the channel. I will make it in English soon. 😃

  • @mounikamallela5881
    @mounikamallela5881 Месяц назад

    Any english video for window functions

  • @Ashis_Kumar90
    @Ashis_Kumar90 Год назад

    Clear and Crisp

  • @varunl6948
    @varunl6948 10 месяцев назад

    Thanks for this!

  • @zohebakber5056
    @zohebakber5056 2 года назад

    nicely explained, bro

  • @shashikiran6859
    @shashikiran6859 2 года назад

    Great Explanation