SQL Ranking Window Functions | ROW_NUMBER, RANK, DENSE_RANK, NTILE, CUME_DIST, PERCENT_RANK

Sdílet
Vložit
  • čas přidán 20. 08. 2024

Komentáře • 50

  • @DataWithBaraa
    @DataWithBaraa  Před 3 měsíci +1

    If you want to see more videos like this, Subscribe for more data tutorials like this :) bit.ly/3GiCVUE
    ⏱ TIMESTAMPS ⏱
    ---------------------------------
    00:00 Intro
    00:00:28 What are Window Ranking Functions?
    00:05:48 ROW_NUMBER
    00:10:13 RANK
    00:14:18 DENSE_RANK
    00:18:42 ROW_NUMBER vs RANK vs DENSE_RANK
    00:19:45 ROW_NUMBER: TOP-N Analysis
    00:23:24 ROW_NUMBER: Bottom-N Analysis
    00:27:00 ROW_NUMBER: Assign Unique IDs
    00:29:47 ROW_NUMBER: Identify Duplicates
    00:35:21 NTILE
    00:41:41 NTILE: Data Segmentation
    00:45:35 NTILE: Equalizing Loads
    00:49:02 Intro Percentage Based Ranking
    00:50:10 CUME_DIST
    00:53:52 PERCENT_RANK
    01:01:40 Summary
    Enjoy ☕

  • @mohammadthousif7439
    @mohammadthousif7439 Před 29 dny +4

    Greatest tutorial on ranking functions across entire internet ever.

  • @sapbo2284
    @sapbo2284 Před 3 měsíci +7

    Hi Baraa, Hope you are doing well! Baraa you might don't know how much you are helping people like me.Thanks a million

  • @davidcere16ceresuela28
    @davidcere16ceresuela28 Před 2 měsíci +4

    Hi Baraa, you don't realize how amazing your work is! Please, keep it up with the tutorials!! Thanks :)

    • @DataWithBaraa
      @DataWithBaraa  Před 2 měsíci

      And you don't realize how awesome you are, when you take time a writing me this nice comment 🙂

  • @fatmaabduarrahman7590
    @fatmaabduarrahman7590 Před měsícem +2

    I wonder why something like this doesn't have at least hundreds of thousands of views. Thanks for you efforts

    • @DataWithBaraa
      @DataWithBaraa  Před měsícem

      With your people like you supporting, maybe my content will reach the others ❤️

  • @narragopichand9982
    @narragopichand9982 Před měsícem +1

    I didn’t seen any videos on sql with immense detailed explanations.

  • @Bhargavi-vz1zt
    @Bhargavi-vz1zt Před měsícem +2

    Thank you Baraa! very Informative and I was able to crack my SQL interview because of your SQL videos..

  • @ccnebechukwu
    @ccnebechukwu Před 21 hodinou

    Best teacher ever...🎉

  • @sowmya6471
    @sowmya6471 Před 2 měsíci +1

    Thanks for introducing advance concept Cume_dist(). It is gonna help me in my office work.

  • @wanggang2396
    @wanggang2396 Před 3 dny +1

    This is definitely the clearest explanation of any tutorial I've ever seen, and I fell in love with this way of thinking analytically, thank you so much for the tutorial.
    By the way, what software do you use to do these visual explanations, and I also want to learn this way to understand complex problems in depth.

    • @DataWithBaraa
      @DataWithBaraa  Před 3 dny

      Hi thanks for the kind words, glad you liked it. I am using drawio and procreate

  • @sagargaryali1345
    @sagargaryali1345 Před 9 dny +1

    Hi Baraa,
    You have made learning so easy and fun. Thank you so much for all the guidance.
    Can you please make videos on query optimization, tuning, indexation as well please.

  • @devinanissa7928
    @devinanissa7928 Před 2 měsíci +1

    I really feel blessed that you made this all video. It's really interesting and easy to understand. when the 1st time i watched your video, i am immediately subscribe!! Great Job Baraa!! Thank you

    • @DataWithBaraa
      @DataWithBaraa  Před 2 měsíci

      I am aswell blessed to be able to reach kind people like you, thanks for the support and glad you liked it

  • @My_query
    @My_query Před 2 měsíci +1

    Keep doing it bro your explanation makes more sense I bet you.

  • @ransfordsaddicamoleka2924
    @ransfordsaddicamoleka2924 Před měsícem +1

    Thanks very much Baraa

  • @santoshkiran5858
    @santoshkiran5858 Před 3 měsíci +1

    I'm starting to get the hang of SQL from you're tutorial lecture Simply Brilliant ❤❤❤

  • @talkwithjyoti1883
    @talkwithjyoti1883 Před 2 měsíci +1

    your teaching style is mind blowing

  • @micaelzekarias1537
    @micaelzekarias1537 Před 3 měsíci

    As always I have no word to thank you. God bless u wherever u r.

  • @sarphoah
    @sarphoah Před 2 měsíci +1

    Thank you so much Baraa! Your videos are so helpful. I appreciate the effort you put into them. Can you please do a video on handling different Date types in SQL?

    • @DataWithBaraa
      @DataWithBaraa  Před měsícem

      Thank for the kind words, yes I’ll cover it in my course!

  • @andrescorrea9640
    @andrescorrea9640 Před 3 měsíci +1

    Outstanding! 👏🏻👏🏻👏🏻
    Thank you so much!

  • @CuocSongQuanhTa204
    @CuocSongQuanhTa204 Před 3 měsíci +1

    Thanks Baraa as always!

  • @mdanisurrahman357
    @mdanisurrahman357 Před 3 měsíci +1

    Awesome,, pls keep making more extraordinary videos

  • @azaansfunworld4300
    @azaansfunworld4300 Před 3 měsíci

    I am excited even before going through the video ….i am sure I m going to enjoy this … Thanqqqqqq

  • @daayush6654
    @daayush6654 Před 12 dny +1

    Amazing explanations with the visualization 🐐.
    Btw is that Nescafe your super hot coffee ☕ or air purifier🍀

  • @venkateshperumal4222
    @venkateshperumal4222 Před 3 měsíci +1

    Thank you so much, was waiting for this video eagerly!!!

    • @DataWithBaraa
      @DataWithBaraa  Před 3 měsíci

      You are welcome, i hope you will enjoy it !

  • @OPTIMUSPRIME-q8x
    @OPTIMUSPRIME-q8x Před 3 dny +1

    time to sit and learn

    • @DataWithBaraa
      @DataWithBaraa  Před 3 dny

      @@OPTIMUSPRIME-q8x good luck hope you enjoy it and don’t forget your coffee:)

  • @jaideepthanage4934
    @jaideepthanage4934 Před 3 měsíci

    Was waiting for this eagerly!❤

  • @golden_melodies
    @golden_melodies Před 3 měsíci

    Thanks alot

  • @SheikhMohammadHussain-e7i

    Hi Baraa, I wanted to ask something, if I use three RANK function in a query but partition those by three different expressions, the result is a bit confusing? What is the order of execution and how does it work? Example:
    SELECT
    OrderID,
    OrderDate,
    ProductID,
    Sales,
    RANK() OVER(PARTITION BY ProductID ORDER BY SALES DESC) AS RankSales,
    RANK() OVER(PARTITION BY OrderID ORDER BY SALES DESC) AS RankSales,
    DENSE_RANK() OVER(PARTITION BY ProductID ORDER BY SALES DESC) AS DenseRankSales
    FROM Sales.Orders
    And Thanks for being the best teacher ever

    • @DataWithBaraa
      @DataWithBaraa  Před 14 dny +1

      Thanks for kind words and great question !!
      Here's an explanation:
      The key here is to understand that each RANK function operates independently! Based on your query the data will be partitioned three times and sorted three times.
      For example:
      RANK() OVER(PARTITION BY ProductID ORDER BY SALES DESC) ranks sales within each product.
      RANK() OVER(PARTITION BY OrderID ORDER BY SALES DESC) ranks sales within each order.
      DENSE_RANK() OVER(PARTITION BY ProductID ORDER BY SALES DESC) gives a dense rank within each product.
      So each one of them will be executed independently. I hope this helps.

    • @SheikhMohammadHussain-e7i
      @SheikhMohammadHussain-e7i Před 14 dny +1

      @@DataWithBaraa Thanks a lot ! Now it's clear.

  • @joewerger8845
    @joewerger8845 Před 26 dny

    what is the letter t after the query

  • @anuboluwaji635
    @anuboluwaji635 Před 3 měsíci

    Hi Baraa, hope all is well. Question: do you know MySQL and if you do, can you please do a tutorial on it?

  • @jacksmith4257
    @jacksmith4257 Před měsícem

    Whether all of this work same in MySQL server

  • @gopikrishnasistla8896
    @gopikrishnasistla8896 Před 3 měsíci

    ITALY and SQL both are beautiful only by Baraa sir.
    From sales.orders) t where rank byproduct=1
    Above query after bracket the letter t comes. What it mean
    Thank you sir

    • @DataWithBaraa
      @DataWithBaraa  Před 3 měsíci

      Italy is very lovely and amazing culture.
      The letter t that comes after the closing bracket in your query is an alias for the subquery. In SQL, you can assign an alias to a table or a subquery to simplify references to it in the rest of your query. In SQL Server it is required to give an Alias after each subquery.

    • @gopikrishnasistla8896
      @gopikrishnasistla8896 Před 3 měsíci

      @@DataWithBaraa thank you sir