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 - Наука та технологія
Great video. Thanks for keeping these out there for us to refer to as we find ourselves in a jam.
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.
Thanks so much.
Finally, I understood the window functions easily...Thanks alot
Glad I could help.
Step by step - the only way to learn. Thank you, Brad.
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.
I cant hear it :D
Now I started to notice it.. Thanks mate :)
Excellent and palpable presentation of something that sounds abstract in thought. These videos are very helpful!
Thanks for the positive feedback
This should have waaaay more views
I found window function to be complex to understand but you have explained them very beautifully!! Thanks for the short videos.
4:02 and 6:05
( ) are parentheses.
[ ] are brackets.
{ } are braces or curly brackets.
Done thanks for great video, took notes
I am wondering why this channel doesn't get the attention it deserves?
I wonder that myself, will start producing some new videos shortly.
@@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. 👍
well bloody done BD! I'm learning a lot from you.
Oh this helped make it so easy to understand. Thank you BeardedDev!
You sir are an amazing teacher!
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.
Hi Krishna, I'm well thank you, there will be a lot of content coming this year including more on Azure and Power BI
thanks for the fantastic video
Extremely helpful video (and playlist), kudos!
Thanks so much, I will have some new videos up over the next couple of weeks
Great explanation!
Another great explanation video! I like the way you teach, mate! Tks
Thanks so much, new videos coming early next year
Keep up the good work!
THANK YOU!
Nice short videos well explained. Thanks!
Thanks very much
Love your channel thanks so much!
With help of your videos I cleared my technical round yay :D
They asked window functions.
Excellent fabulous awesome lecture 🙌🙌
Love from Pakistan ! I'm learning a lot from you, Stay blessed.
Thanks
Hi, thanks for the amazing videos. Would be really helpful if we could have session on self joins.
Thanks for the feedback, I will post a video on self joins next week and let you know when it’s online.
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 :)
Thank you so much for sharing this. Can you please share table script?
Could we get access to the Table that you're using in this Video?
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?
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.
@@BeardedDevData yes, go it. Thanks, saves me rooting round in YT for them!
Here is the link: SQL Tutorials: ua-cam.com/play/PLgR-BOYibnN0qAHzuVOLPNDDM3JfB7o5_.html
Thanks for the great videos! Can you please share the data that you are using in your tutorials?
Hi, I have started to incorporate this in my newer videos
At 4:53, order by inside over clause is ordering by sales total? Can't understand that.
Sales_Total is a column in the table.
407 all positive, 0 negativ. 2020/11/29
I can’t change video quality from mobile app this first time to face it
Appreciate that, I have used some new software in my latest videos that allows zooming.
Too small font! :(
Appreciate that, I will be increasing the font size and zooming in, in future videos.
BeardedDev really good explanation of window function.