Learn GROUP BY vs PARTITION BY in SQL

  Рет қаралды 37,062

Anthony Smoak

Anthony Smoak

Күн бұрын

While the Group BY clause is fairly standard in SQL, most people do not understand when to use the PARTITION BY clause. This easy to understand video uses some NBA season data to make the point very clear! I will show you the best use case of when to apply PARTITION BY.
#SQL #analytics #tsql #groupby #dataanalyst #data
★☆★ Join this channel to get access to perks: ★☆★
/ @anthonysmoak
★☆★ FOLLOW ME BELOW: ★☆★
Blog ► anthonysmoak.com/
Twitter ► / anthonysmoak
Facebook ► / anthonybsmoak
Instagram ► / @anthonysmoakdata
Tableau Public ► bit.ly/3JMKsLY

Пікірлер: 109
@Findawaytomak3it
@Findawaytomak3it 6 ай бұрын
Dude, I havent even finished watching the video yet...had to pause it to PARTITION a Subscribe and Like. AWESOME WORK ANTHONY!!!!!!
@AnthonySmoak
@AnthonySmoak 6 ай бұрын
This is one the best comments I've ever read on one of my videos! Thanks for making my day 😂
@Findawaytomak3it
@Findawaytomak3it 6 ай бұрын
@@AnthonySmoak Im glad it made your day. Keep rock'n on brother!🙂
@thehunter11
@thehunter11 2 ай бұрын
We're having a serious PARTITIONING case here. You the truth man, thanks.
@AnthonySmoak
@AnthonySmoak 2 ай бұрын
You're the real MVP, thanks for the comment!
@saurabhbhende4231
@saurabhbhende4231 Жыл бұрын
best video I found on youtube which explains diff between GROUP BY and PARTITION BY so clearly, thanks a lot for the video...
@AnthonySmoak
@AnthonySmoak Жыл бұрын
Thanks for the kind words!
@andresgutierrez7504
@andresgutierrez7504 10 ай бұрын
x2
@godwinnwaokike
@godwinnwaokike 5 ай бұрын
Just yesterday, I was frustrated at not being able to understand the PARTITION BY clause after trying to. Today, your video has solved that for me in a spectacular way. Thank you.
@AnthonySmoak
@AnthonySmoak 5 ай бұрын
It can be a bit confusing, but I find that a good sports example helps make the differences understandable. Thanks for sharing your comment!
@klausbighi7045
@klausbighi7045 Жыл бұрын
I didn't found a better example and a clearer approach even in my native language. Great video!
@AnthonySmoak
@AnthonySmoak Жыл бұрын
Thank you for sharing!
@shannont44
@shannont44 Жыл бұрын
Dope example! Was able to take your example and apply it to some actual real work problems.
@AnthonySmoak
@AnthonySmoak Жыл бұрын
Glad to hear this, thanks anks for the comment!
@katholloman1922
@katholloman1922 7 ай бұрын
Thank you. Partition by was a topic we absolutely covered in college, but I didn’t think much of it. Now that I’m in the field, I’m in a situation where I need to understand partition by for this project. Now I have that knowledge, thanks!
@AnthonySmoak
@AnthonySmoak 7 ай бұрын
Glad I help you learn something new!
@BedirBayar
@BedirBayar 25 күн бұрын
That was a crystal clear lesson. Thanks
@AnthonySmoak
@AnthonySmoak 24 күн бұрын
@@BedirBayar Thanks for the comment!
@luistrejo2987
@luistrejo2987 4 ай бұрын
this has been one of the most insighful videos i´ve seen so far in my journey of SQL learning, THANKS for this, it has clarified a lot of things! You´ve got yourself a new sub
@AnthonySmoak
@AnthonySmoak 4 ай бұрын
Thank you so much for sharing this comment Luis! It's a lot of work to run this channel and I appreciate viewers who share that my videos are making a difference.
@kailashsathia3080
@kailashsathia3080 2 ай бұрын
LOVE YOUR CONTENT. HELPED ME A TON AT WORK.
@AnthonySmoak
@AnthonySmoak 2 ай бұрын
I'm very glad to hear that, thanks for sharing!
@kanchan-kulkarni407
@kanchan-kulkarni407 10 ай бұрын
This is the best video I found which explains diff between GROUP BY and PARTITION BY so clearly, that helped me a lot. thank you very much!.
@AnthonySmoak
@AnthonySmoak 10 ай бұрын
Thank you for sharing!
@brandongarza1366
@brandongarza1366 Жыл бұрын
Excellent content, this really helped me understand this concept. Using a real world example for things I actually care about makes this much more engaging too. Thanks!
@AnthonySmoak
@AnthonySmoak Жыл бұрын
Thanks for this feedback! I try to make content relevant to concepts outside of business data every now and then.
@ChrisSmithFW
@ChrisSmithFW 5 ай бұрын
Great stuff! Thanks so much. And that's Shaq and Penny.
@AnthonySmoak
@AnthonySmoak 5 ай бұрын
Thank you, Shaq and Penny should have won many championships together!🏆
@seshulatha
@seshulatha 11 ай бұрын
I got full clarity after watching this video ..thank you for this excellent explanation 🎉
@AnthonySmoak
@AnthonySmoak 11 ай бұрын
Glad it helped!
@kennymontero8610
@kennymontero8610 Жыл бұрын
Usually never comment on these kind of videos but this one I had to. Amazing tutorial with a real life topic/example that is interesting. I was cracking up at "2021 Play in Game Champs". Subscribed and Liked. Appreciate you boss.
@AnthonySmoak
@AnthonySmoak Жыл бұрын
Thanks for taking the time to comment. It helps content be discovered. Can you imagine the celebration if the TWolves won an actual NBA title?!
@fidi7400
@fidi7400 3 ай бұрын
Thanks so much, you really helped me understanding grouping by and partition by. My lines of code now work as intended!
@AnthonySmoak
@AnthonySmoak 3 ай бұрын
Fantastic, glad to hear that you learned something new!
@monicabright2903
@monicabright2903 Жыл бұрын
Thank you for this! this was so so super easy, simple and straightforward to understand. thank you.
@AnthonySmoak
@AnthonySmoak Жыл бұрын
I appreciate you sharing this comment. Thank you Monica!
@andigashi4852
@andigashi4852 Жыл бұрын
excellent! You are the only one that explained this subject for my understanding.Thank you!
@AnthonySmoak
@AnthonySmoak Жыл бұрын
Thank you for the comment! Glad you learned something new.
@AnthonySmoak
@AnthonySmoak Жыл бұрын
Has this video helped you understand the PARTITION BY concept? What use cases have you used the statement to help you complete?
@simpleandminimalmaybe
@simpleandminimalmaybe Жыл бұрын
yes, and thank you very much for explaining in a clear and concise manner. greatly appreciate it.
@AnthonySmoak
@AnthonySmoak Жыл бұрын
@@simpleandminimalmaybe Wonderful! Thanks for the feedback
@kseniyab2359
@kseniyab2359 5 ай бұрын
Super useful, thank you! 💚
@AnthonySmoak
@AnthonySmoak 5 ай бұрын
Thank you!
@brickmedusa
@brickmedusa 5 ай бұрын
Thank you so much finally inwas able to understand this concept
@obafemijoel6706
@obafemijoel6706 4 ай бұрын
This is really insightful Anthony! You explained it in a very simple fashion. Wanted asking to know if I can get a percentage difference for the points instead of just the difference from the average?
@AnthonySmoak
@AnthonySmoak 4 ай бұрын
Certainly, just apply the formula for percent difference from the average.
@s961201
@s961201 10 ай бұрын
Great video!!! So educational - very pedagogically explained. Thanks!
@AnthonySmoak
@AnthonySmoak 10 ай бұрын
Thank you so much for the feedback!
@asqalith6998
@asqalith6998 Жыл бұрын
You are amazing , you made this topic so simple for me
@AnthonySmoak
@AnthonySmoak Жыл бұрын
I appreciate the comment, thank you!
@wilshawn3347
@wilshawn3347 11 ай бұрын
Great stuff and well executed, The concept is now very clear to me. Thank you,👍
@AnthonySmoak
@AnthonySmoak 11 ай бұрын
I'm glad you shared that my video helped make the concept clear. It makes my day when someone learns something new from what I create and share. Thank you!
@wilshawn3347
@wilshawn3347 11 ай бұрын
Hi Anthony, can you kindly share the NBA data used in this video? I would like that for my learning
@AnthonySmoak
@AnthonySmoak 11 ай бұрын
I don't usually share datasets (because I get more requests than I have time to respond to) but share your email here and I'll see what I can do. You can hunt for similar stats at www.basketball-reference.com/
@aspirationalaudio4025
@aspirationalaudio4025 3 ай бұрын
Really Thank you for your explanation 😍😍 a New Like and subscription From Egypt 🤙
@AnthonySmoak
@AnthonySmoak 3 ай бұрын
Thank you for supporting the channel!
@shyiamnot212
@shyiamnot212 Жыл бұрын
Very understandable content. It explained the concept very detailed.
@AnthonySmoak
@AnthonySmoak Жыл бұрын
Thank you!
@whitemask-Community
@whitemask-Community 9 ай бұрын
Great Vid, Informative, Crisp, Clear 👌👍
@MrAlgorhythm
@MrAlgorhythm Жыл бұрын
Well explained, clear, usefull, and accompanied by smooth beats to boot.
@AnthonySmoak
@AnthonySmoak Жыл бұрын
Thank you for sharing! I'm aIways grateful when a video helps someone understand. Glad you dig the tunes as well.
@pa-ogaming4004
@pa-ogaming4004 Жыл бұрын
Thank you very much !!
@AnthonySmoak
@AnthonySmoak Жыл бұрын
Glad you enjoyed the video!
@kiranyeluru7392
@kiranyeluru7392 Жыл бұрын
Wonderful Next level of teaching Anthony, Really great to watch difficult topic you made it as easy , Could you please suggest some good books to learn MySQL , Anthony
@AnthonySmoak
@AnthonySmoak Жыл бұрын
Thanks for the kind works Kiran! There are many courses around to learn MySQL. I dont have a particular recommendation, but just pick one and go for it!
@Craeson1
@Craeson1 Жыл бұрын
Thank you for the clear explanation
@AnthonySmoak
@AnthonySmoak Жыл бұрын
Glad the video helped break down the differences for you!
@sabinsesumariyan3687
@sabinsesumariyan3687 7 ай бұрын
great thanks anthony
@AnthonySmoak
@AnthonySmoak 7 ай бұрын
Thanks for the comment!
@aichoices7174
@aichoices7174 Жыл бұрын
thanks for ur explanatiom
@AnthonySmoak
@AnthonySmoak Жыл бұрын
Thanks for watching and leaving a comment!
@A_View_From_The_Shire
@A_View_From_The_Shire Жыл бұрын
Very clear. Thank you!
@AnthonySmoak
@AnthonySmoak Жыл бұрын
Much appreciated!
@LovelyJordy
@LovelyJordy Жыл бұрын
Loved this thank you Anthony 🎉.
@AnthonySmoak
@AnthonySmoak Жыл бұрын
Thanks for the comment Jordan
@testpurpose5845
@testpurpose5845 11 ай бұрын
Great explanation . I really appreciate . Btw where can I find the sql table entries ?
@saystephen7811
@saystephen7811 3 күн бұрын
i love it
@AnthonySmoak
@AnthonySmoak 3 күн бұрын
Thank you?
@sylviejohnsimagorganics3575
@sylviejohnsimagorganics3575 Жыл бұрын
Amazing, thank you!!
@dispelDarkness_21
@dispelDarkness_21 3 ай бұрын
bro, nice one. An humble request: kindly turn off background music, its bothering.
@amrishasritharan2617
@amrishasritharan2617 Жыл бұрын
Dope !!!
@HanmyoGeorge
@HanmyoGeorge 4 ай бұрын
Great Tutorial! The background sound was a little distracting for me
@patrickmaldonado229
@patrickmaldonado229 Жыл бұрын
A show of running total using partition by would have been great.
@AnthonySmoak
@AnthonySmoak Жыл бұрын
Perhaps I'll make a short.
@ashokchampati9503
@ashokchampati9503 Жыл бұрын
Awesome 👍
@AnthonySmoak
@AnthonySmoak Жыл бұрын
Thank you!
@saurabh1812
@saurabh1812 Жыл бұрын
what if we have duplicate values in tables? how row_number function will work?
@FlyingDutchman5705
@FlyingDutchman5705 Жыл бұрын
Thank you
@pothamshettyakshay-e2b
@pothamshettyakshay-e2b Жыл бұрын
we can do the same example by using group by
@sylviejohnsimagorganics3575
@sylviejohnsimagorganics3575 Жыл бұрын
Sorry if you've already answered this but which one is better from a performance point of view?
@AnthonySmoak
@AnthonySmoak Жыл бұрын
These are two different operations with different use cases. However, given the need to arrive at an aggregated number, I believe the GROUP BY would provide better performance.
@sylviejohnsimagorganics3575
@sylviejohnsimagorganics3575 Жыл бұрын
@@AnthonySmoak thank you so much. Can't wait to use Partition By soon, I didn't know about it at all!
@dbanoob
@dbanoob Жыл бұрын
LOL @ the random Shaq/Penny
@AnthonySmoak
@AnthonySmoak Жыл бұрын
Good catch!
@hatersgotohell627
@hatersgotohell627 Жыл бұрын
6:53 How come you didn't need to group by the team column as well?
@AnthonySmoak
@AnthonySmoak Жыл бұрын
At that point I am not grouping, I am simply displaying the dimensions. The Over and Partition By help calculate the overall sum of points by each distinct value in the Conference.
@pabitrakb5291
@pabitrakb5291 6 ай бұрын
Nice explanation But background sound is a bit irritating
@shirazahmed5944
@shirazahmed5944 4 ай бұрын
Ok but how can I convert this into LINQ?
@AnthonySmoak
@AnthonySmoak 4 ай бұрын
That is not my area of knowledge, start with ChatGPT.
@3170ccp
@3170ccp Жыл бұрын
Is this for oracle?
@AnthonySmoak
@AnthonySmoak Жыл бұрын
I'm using SQL Server but give Oracle a try.
@PURVAMARGAJ-j3b
@PURVAMARGAJ-j3b Жыл бұрын
share data
@paulpostma6520
@paulpostma6520 2 ай бұрын
Would better without the music - too distracting
@seshulatha
@seshulatha 11 ай бұрын
No background music please
@AnthonySmoak
@AnthonySmoak 11 ай бұрын
Video is already released. Too late! ;)
@nishasilori4222
@nishasilori4222 Жыл бұрын
Please if possible avoid using the background noise while teaching
@AnthonySmoak
@AnthonySmoak Жыл бұрын
But I like "noise" 😂 #music
@TheBinary0101
@TheBinary0101 2 ай бұрын
Super !! thx lots .. subscribed
@AnthonySmoak
@AnthonySmoak 2 ай бұрын
Much appreciated!
Learn WHERE vs HAVING in SQL | SQL Interview Question
9:49
Anthony Smoak
Рет қаралды 653
WORLD BEST MAGIC SECRETS
00:50
MasomkaMagic
Рет қаралды 47 МЛН
when you have plan B 😂
00:11
Andrey Grechka
Рет қаралды 63 МЛН
So Cute 🥰
00:17
dednahype
Рет қаралды 58 МЛН
SCHOOLBOY. Мама флексит 🫣👩🏻
00:41
⚡️КАН АНДРЕЙ⚡️
Рет қаралды 7 МЛН
ОКОННЫЕ ФУНКЦИИ SQL за 13 минут
13:46
Listen IT
Рет қаралды 50 М.
Over clause in SQL Server
9:13
kudvenkat
Рет қаралды 240 М.
Advanced Aggregate Functions in SQL (GROUP BY, HAVING vs. WHERE)
6:00
Becoming a Data Scientist
Рет қаралды 249 М.
WORLD BEST MAGIC SECRETS
00:50
MasomkaMagic
Рет қаралды 47 МЛН