SQL Window Function | How to write SQL Query using Frame Clause, CUME_DIST | SQL Queries Tutorial

Поделиться
HTML-код
  • Опубликовано: 25 июл 2024
  • SQL Window Function. How to write SQL Query using Frame Clause, CUME_DIST. SQL Queries Tutorial.
    This video is about Window Functions in SQL which is also referred to as Analytic Function in some of the RDBMS. SQL Window Functions covered in this video are FIRST_VALUE, LAST_VALUE, NTH_VALUE, NTILE, CUME_DIST and PERCENT_RANK. Also we cover how to use FRAME Clause while writing SQL Queries using window function. We also look at alternate way of writing SQL Query using window function.
    We discuss in detail about the Frame clause and how RANGE is different from ROWS and how to use Unbounded Preceding and Unbounded Following while using certain window functions.
    This is the second video where we talk about window functions in SQL. I have made another video covering other window functions such as RANK, DENSE RANK, LEAD, LAG and ROW NUMBER. Link to the previous video is mentioned below:
    • SQL Window Function | ...
    This video is focused on teaching how to write SQL Queries using different window functions or analytic functions. We go through the syntax of using first value, last value, frame clause, nth value. ntile, cume dist and percent rank as window function in SQL query.
    We look at how to use WINDOW clause while writing SQL query using window functions. We talk about the OVER clause and how partition by clause can impact the result set.
    Over clause is explained in detail in this video. Over clause is used in SQL when we need to use window function. Inside Over clause, we also use Partition By clause and also Order by clause.
    Partition By clause is used to specify the column based on which different windows needs to be created.
    The window function you learn in this video is applicable to any RDBMS since these functions are commonly used across most of the popular RDBMS such as Oracle, MySQL, PostgreSQL, Microsoft SQL Server etc.
    /**** Download all the SQL Queries, Table Structure and Table data used in this video ***/
    Link: techtfq.com/blog/sql-window-f...
    On this page, Click on the button which says "Download SQL Script" to download the .sql file (.sql file can be opened in any text editor)
    Timestamp:
    00:00 Intro
    02:12 FIRST_VALUE
    07:25 LAST_VALUE
    10:25 Frame Clause
    22:26 Alternate way of writing SQL Query using window function using Window clause
    26:41 NTH_VALUE
    31:47 NTILE
    38:02 CUME_DIST
    47:35 PERCENT_RANK
    I hope this video was helpful and gives you a good understanding of how to write SQL Queries using window functions or analytic functions. If you liked what you saw, then please make sure to like, subscribe and comment any feedback you may have.
    Also please do not hesitate to share the video with your friends and colleagues who may be interested in learning SQL
    🔴 WATCH MORE VIDEOS HERE 👇
    ✅ SQL Tutorial - Basic concepts:
    • SQL Tutorial - Basic c...
    ✅ SQL Tutorial - Intermediate concepts:
    • SQL Tutorial - Interme...
    ✅ SQL Tutorial - Advance concepts:
    • SQL Tutorial - Advance...
    ✅ Practice Solving Basic SQL Queries:
    • Practice Solving BASIC...
    ✅ Practice Solving Intermediate SQL Queries:
    • Practice Solving INTER...
    ✅ Practice Solving Complex SQL Queries:
    • Practice Solving COMPL...
    ✅ Data Analytics Career guidance:
    • Data Analytics career ...
    ✅ SQL Course, SQL Training Platform Recommendations:
    • SQL Course / Training
    ✅ Python Tutorial:
    • Python Tutorial
    ✅ Git and GitHub Tutorial:
    • Git and GitHub
    ✅ Data Analytics Projects:
    • Data Analytics Projects
    THANK YOU,
    Thoufiq

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

  • @timmytesla9655
    @timmytesla9655 2 года назад +163

    I never thought I would understand window functions so fast and easily like this. Thank you a million times.

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

      Glad this helped ☺️

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

      turu

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

      same

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

      @@techTFQ
      does the way of window clause not work in SQL SERVER as I am getting error while doing so??
      Below is the query I am using
      @techtfq
      select distinct product_category,
      FIRST_VALUE(product_name) over w as most_expensive_product_in_each_category,
      FIRST_VALUE(price) over w as price_of_most_expensive_product,
      LAST_VALUE(product_name) over w as least_expensive_product_in_each_category,
      LAST_VALUE(price) over w as price_of_least_expensive_product
      from products
      window w as (partition by product_category order by price desc range between unbounded preceding and unbounded following)

  • @aperxmim
    @aperxmim 2 года назад +42

    This is about easy as it gets to understand, just need to practice so these techniques could stay inside my brain. Good Job, better than most college professor teachings.

    • @techTFQ
      @techTFQ  2 года назад +3

      Thank you so much 🙏🏼
      Glad to know you found this helpful 🙂

  • @amaalanoos838
    @amaalanoos838 2 года назад +21

    This is how a tutorial should be. Concise and clear explanation. Greate Job!

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

    I hav spent a lot of money on books a courses but you are the best teacher. I have learned things that were skimmed over elsewhere. Thank you!

  • @saranrajv3
    @saranrajv3 Год назад +20

    I have searched Udemy and many youtube channels to understand the Window functions and finally this video shed the light for an excellent clarity , Once again kudos to Taufiq for an excellent content and clarification :)

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

      Glad it helped!

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

    You sir are a God send. My number 1 port of call when i need sql explained in plain English. On behalf of all your viewers here's a massive THANK YOU.

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

    My good sir, I've been binge watching your videos. Got my Google Analytics diploma and I need as much practical knowledge and practice as I can get my hands on. THANK VERY MUCH for these videos.

  • @satyaece2007
    @satyaece2007 2 года назад +38

    Exceptionally articulated starting with every query and data set explanation and I can't believe it's so easy after hearing to your explanation and it's impressive. It's not easy to watch an hour of new concept continuously but your videos are exception. It's really interesting though I'm pretty new to these concepts. Thanks a lot for making these videos.

    • @techTFQ
      @techTFQ  2 года назад +2

      Very happy to read this feedback Satya ..
      I am very glad you liked it ..
      🙏🏼🙏🏼☺️

  • @artisartisworld8629
    @artisartisworld8629 Год назад +5

    one of the best and easy explanations, even better than what we pay for most of the Udemy courses.

  • @sanjoysaha1697
    @sanjoysaha1697 2 года назад +21

    I have explored so many courses on udemy and on other online platforms but yours is unparallel. Excellent explanation, easy to understand making it stand out from the crowd. You rock man. Thanks for sharing the videos.

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

      Thank you Sanjoy.
      Appreciate the feedback

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

    The goto channel to learn SQL. As a non-tech person, I really appreciate the ease of learning and understanding the language

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

    Now finally I am able to understand completely how and where to use window functions in such a easy way. Thanks a lot for an amazing tutorial !!

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

    Simply mind blowing explanation! Thanks for being a great mentor. Much love and health to you!

  • @nagarajshenoy4848
    @nagarajshenoy4848 День назад

    Unbounded preceding was a tricky one.. Loved the way you explained..

  • @lenzamoya6297
    @lenzamoya6297 День назад

    This was awesome,you made window functions lesson easy for me.

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

    I can't believe how helpful this is. Such a brilliant job. Thank you immensely.

  • @md.jannatultasnim2661
    @md.jannatultasnim2661 Год назад

    you are a great mentor . At first these things were very confusing for me but now i am confident enough to use them. Thank you

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

    This is the best video on Window function I have ever came across. Kudos to you!!

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

    After now on, I can solve any complex problems using window functions .
    Big respect for you!

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

    THE BEST video for the window function

  • @user-fz9ng3se4f
    @user-fz9ng3se4f Год назад

    TechTFQ = Deep Understanding + Great knowledge + Impressive teaching style.

  • @sudippandit9855
    @sudippandit9855 2 года назад +11

    Thank you for your contribution! I really love to see those contributions so that it will make easy to understand the real time projects. Please keep going your good work and hope to see the other more videos like this in the upcoming days😍

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

      Thank you Sudip 🙏🏼
      I am so glad to know you liked my videos ..
      I’ll try my best to post more such useful videos ☺️

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

    Such a good explanation of Window Functions. Thank you!

  • @mmmaxmmm83
    @mmmaxmmm83 2 года назад +3

    This was fantastic! Thank you. Loved your real time examples and simple way of explaining the data and the results.

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

      Thank you 🙏🏼
      I am so glad you liked it 🙂

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

    explanation of the frame was just amazing!
    thank you so much !!

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

    Both the tutorials of window function are gem of video. Really love the way you teach.
    Thank you so much

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

    One of my favorite channel on you tube!!
    Quality content!!!!! Really Thankful to you for sharing this detailed knowledge on window function!

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

    Undoubtedly you have the best video explaining window functions !!

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

    this video is better than any other one in the same topic. Million thanks!

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

    I just started learning SQL and this tutorial saved me. outstanding. Keep going

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

    The videos are so easy to follow. You have simplified the concepts so much, thank you.

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

    You are such an exceptional Teacher....very precise to the concepts and explanation is crisp and clear...Thank you..SQL learning is more easy when I hear from you.

  • @gulaggang6339
    @gulaggang6339 2 года назад +6

    Great video. Looking forward to more advanced sql content. Thanks for the quality content.

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

      Thank you so much 🙏🏼
      Truly appreciate your feedback. Yeah will cover other advanced SQL concepts ☺️

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

    Hello Thaufiq, I’m on my SQL learning journey and came across your channel, thank the RUclips algo lords. Previously, I used to refer to the documentation pages to learn SQL and would easily get lost in understanding nuances. Your succinct explanation on LAST_VALUE() default frame just saved me loads of time. Huge thanks. Subscribed.

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

      Hi Meghana ,
      It means a lot to receive such amazing feedback.. thank you 🙏🏼
      I am so glad my content helped you ..

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

    Thank you so much for this video! I was struggling so hard to understand the window function and the frame clause and I was thinking that is too complicated for me but after watching your video now I feel that I understood it, finally! I am attending a course on SQL and I didn't understand a thing about the window function but in order to pass I need to write a query using the window function and now I will be able to pass thanks to you!

  • @beulahr5740
    @beulahr5740 21 день назад +1

    very useful video. Thank you soooo very much sir

  • @lize.6122
    @lize.6122 6 месяцев назад

    Many thanks for your invaluable contribution to the success of my SQL journey. You are such a lifesaver.

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

    What an explanation! This is awesome. Thank you very much.

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

    Easy explanations. No self advertisement. Absolutely Professional. Good Work Mate

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

    Crystal clear explanation.

  • @SantanuRoy-oq2nv
    @SantanuRoy-oq2nv Год назад

    Outstanding Sir. Thank you for your both Windows functions videos..

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

    Really great video. I think it helped that I wasn't totally new to window functions, but this tied everything together. Very thorough. Thank you thank you!!

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

    Great Job ! Very smooth understanding.

  • @IrakliChitishvili
    @IrakliChitishvili 2 года назад +3

    Great video series, good job! For added bonus - new chapter title intros sound like a slap haha :D. definitely subscribing.

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

      Haha dint realize it sounds like a slap ..
      Still figuring out how to make the video quality better ..
      But thanks for liking the content 🙏🏼👍

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

    best explanation ever seen about window functions. keep rocking sir...

  • @anjanaray1594
    @anjanaray1594 2 года назад +3

    After going through numerous videos on sql and trying to find the best one to understand the concept I found this, truly a gem. quality content easy to understand simplified language is used. watching your videos continuously more than 2 hours. Thanks a lot. please do create projects on sql too after all the concepts.

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

      Thanks a lot Anjana 🙏🏼🙏🏼
      Amazing to receive such feedback .. I am so so glad you liked the video and have benefited from it..
      Surely will be making some videos on SQL projects in the near future..

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

    Good lesson about window functions. Thank you!

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

    Great training!! Thank you.

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

    Great explanation with really good examples

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

    Jazak allah brother

  • @deepikameher9343
    @deepikameher9343 3 месяца назад +1

    Best video ever found on RUclips!! I was scared of SQL queries for all interviews,after going through your videos I have got confidence and creaked interviews as well...Many many thanks to you...the way you explain is superb...Kudos to you !!

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

    It's so clear! How can you explain it in such an understandable way, thank you 3000!

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

    best video on window functions!! thank uu brother ...

  • @sairamuddanda5816
    @sairamuddanda5816 2 года назад +2

    Mind blowing!! Never come across this much clearer explanation in entire world which you have done it. Thanks for this

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

      Glad you liked it bro

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

    your voice and way of teaching don't let anyone go away from the long video length as well. Keep up (y)

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

    Jazakallah khair.. i am learning sql by watching your videos thanks you are a best teacher.

  • @user-gn3ch8ch1b
    @user-gn3ch8ch1b 11 месяцев назад

    Excellent teaching... understood in one go ..

  • @NEG0POS
    @NEG0POS 23 дня назад

    You have awesome skills in explaining complex concepts ! Thx

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

    I'm so glad I stumbled upon your page. My queries skills have improved a lot watching your videos. Keep doing the good work Taofiq.

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

    Your way of exlanation is very simple. You are making SQL very simple and easy. Thank you for your efforts. You are just great.

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

    Thank you for this video, you're a great teacher!

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

    In the context of "unbounded preceding and unbounded following", this was the only time I understood it. Thanks a lot

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

      Happy to know that :)

  • @SidhantPatra
    @SidhantPatra 9 дней назад

    It was so clear and understandable. Thank you so much for such valuable topic🤗

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

    very useful videos , easy to understand

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

    your sql master guide for beginners. toufiq sir.

  • @udaykumar-dl6ux
    @udaykumar-dl6ux Год назад

    All the window functions are very easy to understand. Thanks for explaining very clearly.

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

    You have amazing skills to explain things, cheers for that!!

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

    Hey Toufeeq thank you so much for your work. These are some of the finest study material to better understand the concepts of SQL. I learned a lot about SQL and understood way better than other platforms.
    I have a small doubt on frames and last value(), I do understand last value and frames functions. I understand that frames is the range between unbounded preceding and current row and last value function fetches the last record of any column in a particular partition.
    What I don't understand is how last value function returns record which varies with each row in a partition because even though frames compare each row with unbounded preceding and return the least value, the last function should return the last value in a partition irrespective of whether the record is greater or less than the current row. Last value() returns the last value of a given column in a partition so, Comparison of records should not be a problem here right. So, Iam a bit confused here. Can you please explain the same.
    Thank you

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

    Your way of explanations through queries makes every concept interesting and inspires to learn more.

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

    You're such a gem brother neatly explained such useful concepts in a simple manner... Thank you so much and more power to you 🤝👍

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

    Wow! I understand your content on SQL very easily. Thank you very much. Keep making videos!

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

    I completed a course on advanced sql windows functions on linkdin and in 15 minutes of your video i understood more than i did in that entire course!! kudos to you. I cannot thank you enough !! really really appreciate !! need more tutors like you!!

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

      nth_value is not working on my MS SQL. I copy the codes but still cannot work.

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

    most comprehensive and easy explanation of the most difficult query thank you so much❤❤❤

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

    Superb SQL tutorial!

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

    This is an excellent video. This explains to me why my SQL queries have been delivering funny results. That bit about unbounded preceding and unbounded following is priceless!

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

      Glad it was helpful!

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

    Fantastic stuff. Better than paid courses. Thanks man.

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

    Great way of explanation. Thank You.

  • @tanmaysinghi1868
    @tanmaysinghi1868 2 года назад +3

    your videos have been extremely helpful so far, thank you so much for all this, I wasn't just able to get a quick revision of SQL but also learn few advance concepts.

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

      Thank you Tanmay 🙏🏼
      Glad this helped

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

    Such a clear and excellent explanation.Thank you.

  • @user-sn1rj4gj6g
    @user-sn1rj4gj6g Год назад

    Thank you so much for explaining the windows functions so easily..waiting for your next video..

  • @swatisinha3230
    @swatisinha3230 2 года назад +6

    Thank you for such a fine effort . Explained everything in detail :)

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

      Thanks a lot Swati 🙏🏼
      Happy to know this helped ..

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

    Extraordinary explanation and content. Thanks a lot!

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

    You are such a great person who are providing this all the helpful knowledge freely Thank you so much

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

    default frame k concept p youtube m v bht kam videos hn., but iss vdo m bht mast explanation k sath default frame v clear hogya.

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

    I'm new in sql and your videos are really helpful!
    Thanks a lot

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

    I am so grateful that I stumbled upon this channel. Thank you for making it all so easy !

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

      You are so welcome!
      Glad it helped

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

    Excellent explanation, and yes please make video for additional Windows functions as well. Many thanks!

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

    Thank you! The content is really helpful and easy to understand.

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

    "I am so thankful to you because your videos have made me more interested in learning SQL. I love the way you explain the topics using simple words."

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

    Great and amazing video!! A ton of thanks

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

    Loved and understood everything. Thanks a lot!!!

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

    Excellent tutorial buddy. Keep up the good work and thank you for sharing. Honestly your sql videos are the best.

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

    Respect from the bottom of my heart, Thank you so much for this video. Just wow🤩

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

    very nice, no words to thank !!!!

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

    Sir this video is really helpful for me .Thank you so much

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

    Clear explanation. Look forward to watching your following videos. Thanks.

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

      Awesome, thank you!

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

    You are really good explaining! Thanks a lot

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

    EXECELLENT EXPLAINATION.....VERY EASY TO UNDERSTAND..THANK YOU SO MUCH...GREAT EFFORTS....

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

    Thank for your great video, I always enjoy your explanations

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

    Thanks toufiq for thus great tutorial