SQL Tutorial - Window Functions - Ranking

Поділитися
Вставка
  • Опубліковано 7 лис 2017
  • Another fantastic SQL Tutorial brought to you by BeardedDev.
    If you are new to working with Window Functions check out this video:
    • SQL Tutorial - Window ...
    T-SQL Querying
    www.amazon.com/gp/product/073...
    T-SQL Fundamentals
    www.amazon.com/gp/product/150...
    Microsoft SQL Server 2012 High-Performance T-SQL Using Window Functions
    www.amazon.com/gp/product/073...
    In this video we explore ranking functions available as part of Window Functions:
    ROW_NUMBER()
    RANK()
    DENSE_RANK()
    NTILE()
    This tutorial shows an example of when to use each ranking function and the differences between them.
    Window Functions were first introduced in SQL Server 2005 but further enhancements and support was added in SQL Server 2012.
    We look at the OVER clause and PARTITION BY.
    Window Functions can only be included within SELECT or ORDER BY clauses.
    Functions Available:
    Aggregate - COUNT, SUM, MIN, MAX, AVG
    Ranking - ROW_NUMBER, RANK, DENSE_RANK, NTILE
    Offset - FIRST_VALUE, LAST_VALUE, LEAD, LAG
    Statistical - PERCENT_RANK, CUME_DIST, PERCENTILE_CONT, PERCENTILE_DIST
    Windows Functions also have FRAMES
    ROWS
    RANGE
    Window Functions are a powerful tool within SQL Server and I am excited to bring more videos and tutorials working with Window Functions in the future.
    ROW_NUMBER - unique incrementing integers
    RANK - same rank for same values
    DENSE_RANK - same rank for same values
    NTILE - assigns tile numbers based on number of tiles requested
    SQL:
    SELECT
    Sales_Id
    , Sales_Total
    , ROW_NUMBER() OVER(ORDER BY Sales_Total DESC) AS rownum
    , RANK() OVER(ORDER BY Sales_Total DESC) AS rnk
    , DENSE_RANK() OVER(ORDER BY Sales_Total DESC) AS dense
    , NTILE(3) OVER(ORDER BY Sales_Total DESC) AS ntle
    FROM dbo.Sales_2
    SELECT
    Sales_Id
    , NTILE(10) OVER(ORDER BY Sales_Total DESC) AS ntle
    FROM dbo.Sales_2
  • Наука та технологія

КОМЕНТАРІ • 57

  • @OldPick-Unix-dude-pb9jg
    @OldPick-Unix-dude-pb9jg 10 місяців тому +2

    Great video. Thanks for keeping these out there for us to refer to as we find ourselves in a jam.

  • @rajatb22
    @rajatb22 3 роки тому +6

    I have gone through many videos on UA-cam and also some paid content on many different sites but hands-down this is the best series on window functions.

  • @revathisubhasht
    @revathisubhasht 24 дні тому +1

    Finally, I understood the window functions easily...Thanks alot

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

    Step by step - the only way to learn. Thank you, Brad.

  • @pondmarketplaces
    @pondmarketplaces 3 роки тому +3

    Every single video you can hear his hands rubbing against each other while he talks, but I'm not complaining. He's giving me free knowledge.

  • @bradbyington6662
    @bradbyington6662 6 років тому +20

    Excellent and palpable presentation of something that sounds abstract in thought. These videos are very helpful!

  • @brolino11
    @brolino11 5 років тому +11

    This should have waaaay more views

  • @priyadhandev
    @priyadhandev 4 роки тому +5

    I found window function to be complex to understand but you have explained them very beautifully!! Thanks for the short videos.

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

    4:02 and 6:05
    ( ) are parentheses.
    [ ] are brackets.
    { } are braces or curly brackets.

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

    Done thanks for great video, took notes

  • @Jalalx
    @Jalalx 5 років тому +8

    I am wondering why this channel doesn't get the attention it deserves?

    • @BeardedDevData
      @BeardedDevData  5 років тому +3

      I wonder that myself, will start producing some new videos shortly.

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

      @@BeardedDevData See my comments. Also, search for "how to promote a youtube channel" and see what makes sense to you. THANK YOU FOR THE CONTENT. 👍

  • @nickarrigo5540
    @nickarrigo5540 3 роки тому +2

    well bloody done BD! I'm learning a lot from you.

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

    Oh this helped make it so easy to understand. Thank you BeardedDev!

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

    You sir are an amazing teacher!

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

    I'm glad I found this channel. The videos are very helpful. You don't seem to be active these days, hope you are doing great.

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

      Hi Krishna, I'm well thank you, there will be a lot of content coming this year including more on Azure and Power BI

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

    thanks for the fantastic video

  • @nateslaptop8991
    @nateslaptop8991 4 роки тому +2

    Extremely helpful video (and playlist), kudos!

    • @BeardedDevData
      @BeardedDevData  4 роки тому

      Thanks so much, I will have some new videos up over the next couple of weeks

  • @ElvisSCL
    @ElvisSCL 4 роки тому +1

    Great explanation!

  • @fernandocamargo2637
    @fernandocamargo2637 4 роки тому +1

    Another great explanation video! I like the way you teach, mate! Tks

    • @BeardedDevData
      @BeardedDevData  4 роки тому

      Thanks so much, new videos coming early next year

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

    Keep up the good work!

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

    THANK YOU!

  • @lemmiTry
    @lemmiTry 5 років тому +1

    Nice short videos well explained. Thanks!

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

    Love your channel thanks so much!

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

      With help of your videos I cleared my technical round yay :D
      They asked window functions.

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

    Excellent fabulous awesome lecture 🙌🙌

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

    Love from Pakistan ! I'm learning a lot from you, Stay blessed.

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

    Thanks

  • @nishantkumar-lw6ce
    @nishantkumar-lw6ce 5 років тому +2

    Hi, thanks for the amazing videos. Would be really helpful if we could have session on self joins.

    • @BeardedDevData
      @BeardedDevData  5 років тому

      Thanks for the feedback, I will post a video on self joins next week and let you know when it’s online.

    • @nishantkumar-lw6ce
      @nishantkumar-lw6ce 5 років тому +1

      Thank you so much. One suggestion : I know that your videos are amazing. Please consider different use cases of self joins with examples such as hierarchical use case, sequential use case and network graph for example. Please consider simple to complex use cases :) Waiting for your videos next week! Thanks again :)

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

    Thank you so much for sharing this. Can you please share table script?

  • @ssurekha1
    @ssurekha1 4 роки тому +2

    Could we get access to the Table that you're using in this Video?

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

    I am going to watch the entire series of BeardedDev SQL tutorials as they are so good. Is there an easy way to save them all in one go without having to do it individually for each tutorial?

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

      Hi Mark, there is a playlist on my channel called SQL Tutorials that contains majority of my videos, you can watch that, also I am starting to work on new content now, if there are any particular areas you'd like covering please do let me know.

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

      @@BeardedDevData yes, go it. Thanks, saves me rooting round in YT for them!

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

      Here is the link: SQL Tutorials: ua-cam.com/play/PLgR-BOYibnN0qAHzuVOLPNDDM3JfB7o5_.html

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

    Thanks for the great videos! Can you please share the data that you are using in your tutorials?

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

      Hi, I have started to incorporate this in my newer videos

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

    At 4:53, order by inside over clause is ordering by sales total? Can't understand that.

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

    407 all positive, 0 negativ. 2020/11/29

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

    I can’t change video quality from mobile app this first time to face it

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

      Appreciate that, I have used some new software in my latest videos that allows zooming.

  • @indirameduri9853
    @indirameduri9853 4 роки тому +1

    Too small font! :(

    • @BeardedDevData
      @BeardedDevData  4 роки тому

      Appreciate that, I will be increasing the font size and zooming in, in future videos.

    • @indirameduri9853
      @indirameduri9853 4 роки тому +1

      BeardedDev really good explanation of window function.