SQL WITH Statements (Common Table Expressions - CTE)

Поделиться
HTML-код
  • Опубликовано: 8 фев 2020
  • Step-by-step tutorial shows you how to use the WITH statement in SQL to create Common Table Expressions (CTE)!
    Watch the Subquery video: • How to do Subqueries i...
    Get the Northwind Database: • How to Load a Sample P...
    Support the Channel:
    1) Subscribe: www.becomingads.com/o/youtube
    2) DataCamp:
    3) Udacity:
  • НаукаНаука

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

  • @roodyg5352
    @roodyg5352 5 месяцев назад +2

    Thank you! This video helped me understand CTEs a little bit better.

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

    You explained it so well and fast I'm now fully prepared for what may come

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

    Simple and easy to understand explanation. It really made understanding the WITH statement so simpler. Thanks much.

  • @meanpillscasper
    @meanpillscasper 2 года назад +9

    Just a small correction, using the with statement makes indeed things easier to read and debug but the program won't be any faster. It's just a thing you should do to help other humans understand your code.

  • @jude3026
    @jude3026 3 года назад +1

    U ROCK. im going through your channel and god you couldnt get less helpful. thanks man

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

    Thank you for the video, very clear, I like the format, it's straightforward and very well explained!

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

    Thanks, mate! Your explanation is very easy to understand.

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

    Dude! thank you for taking the time to break down cte's simplified (subquery >> cte). Bro, you rock!!! 😎🤟

  • @atothezeezee
    @atothezeezee 4 года назад +5

    This was excellent - thank you.

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

    Great video! This helped me run a complex query at work. Thanks 😀

  • @amare_._
    @amare_._ 3 года назад +1

    This is clearer than my textbook explanation lol thanks for the video!

  • @RodrigoCruz-iz3kb
    @RodrigoCruz-iz3kb 3 года назад

    Your video helped me a lot, thank You my friend!

  • @ukaszk.8305
    @ukaszk.8305 3 года назад +1

    You are a sensation! Please, keep going :)

  • @danielmejia8530
    @danielmejia8530 3 года назад

    Nice man! subscribing....
    Greetings from Colombia!

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

    Hi Nathan, thanks for explaining me CTE Objects. It's know very clear to me. Appriciate

  • @manideepgupta2433
    @manideepgupta2433 3 года назад

    Finally!! Whoa! Thanks man.

  • @user-bx8ow4xg6h
    @user-bx8ow4xg6h 2 месяца назад

    Thanks a lot for simple explanation

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

    Thanks, easy and straight forward!

  • @jasonwalker4155
    @jasonwalker4155 3 года назад

    ahhh That makes it much clearer. Thank you!

  • @waldojams
    @waldojams 2 года назад +5

    Thanks for the video. I was looking for more info about caching, but noticed (after some reading) that the caching doesn't happen because of the CTE, but instead, it's decided arbitrarily by Postgres. So for instance, either doing subqueries or CTEs might result in the same performance in the end, even though CTEs makes code more readable.

  • @zhiyizhang9102
    @zhiyizhang9102 3 года назад

    great example and explanation!

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

    Thanks! Liked, Commented and Subscribed!

  • @ericsims3368
    @ericsims3368 3 года назад

    Super helpful - thanks a bunch!

  • @amberjones6191
    @amberjones6191 3 года назад

    That was super helpful!

  • @daniellakshan
    @daniellakshan 3 года назад +1

    thanks bro, you saved a lot of time

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

    Sweet and simple: thanks!

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

    Thank you for this very useful video!

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

    The way you describe what cte's are made all the difference. It's so simple when you know yhe why for the how.

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

    Best explanation ever!! 👍

  • @moisefonguendegue5078
    @moisefonguendegue5078 3 года назад

    Good explanation. God bless you. AMEN.

  • @oualidben5660
    @oualidben5660 3 года назад

    Very clear, Thank You Sir !

  • @ghinwamoujaes9059
    @ghinwamoujaes9059 3 года назад

    This is great!

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

    Great video!

  • @hereandnow8578
    @hereandnow8578 3 года назад

    clear and concise. ty

  • @vitalykolesov9434
    @vitalykolesov9434 3 года назад

    Hvala puno!

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

    Thankful for your videos - super helpful! Do you have to use a GROUP BY clause when using CTE's?

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

      It's not a requirement but you certainly could

  • @BilalAli-gr3ry
    @BilalAli-gr3ry Год назад

    Very helpful..... Love from India

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

    Great explanation

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

    Nice video, thank you

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

    hats off!!

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

    thankyou sir, it really helped me.

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

    Thanks!

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

    conceptual and easy way to describe

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

    Super sir 👍👍👍

  • @andyn6053
    @andyn6053 3 года назад

    what is the difference between cte:s and temp tables? temp tables are only stored temporarly and cant be accessed as an cte?

  • @mabblers
    @mabblers 3 года назад

    Excellent explanation . How dose work when you're working with 10 tables and 5 has millions of records in them? Is this viable considering this is all done in memory?
    Thanks

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

      In most database systems, the 'name' of the CTE simply references an internal temporary table that is invisible to you (unless you select from it). So, in effect, the results of the CTE will create a temporary table behind the scenes in order to hold the results of the CTE. It is deleted automatically when you go out of scope of the CTE.

  • @haramrit09k
    @haramrit09k 3 года назад

    Definitely helpful! Thank you for this. Can you also do a video on recursive CTEs?

    • @anthonyedison2388
      @anthonyedison2388 3 года назад

      i know Im kinda off topic but does anyone know a good site to watch new movies online?

    • @kamerondeacon3657
      @kamerondeacon3657 3 года назад

      @Anthony Edison I use FlixZone. Just google for it =)

    • @jaxonatlas1592
      @jaxonatlas1592 3 года назад

      @Kameron Deacon yea, I've been watching on FlixZone for since april myself =)

    • @anthonyedison2388
      @anthonyedison2388 3 года назад

      @Kameron Deacon thanks, I signed up and it seems to work =) I really appreciate it !

    • @kamerondeacon3657
      @kamerondeacon3657 3 года назад

      @Anthony Edison happy to help xD

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

    in the 3rd example nothing changed when you joined another cte. So why did you join them?

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

    hello there, god bless your efforts..I have a simple enquiry as new sql learner.
    How are CTEs different from temporary tables?
    Thanks for taking care of this.

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

      A temporary table will exist during the entire duration of the session whereas a CTE is a "named result set" that exists for the duration of the statement immediately following it. If you would like to persist the results of the CTE, then use the CTE to populate a temporary table for processing later. Hope this clears things up

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

    How can I union two cte together, there is one sum on a budget, column are exactly the same I have group by , send me video please

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

    I've been studying SQL now for about 6 months....I think the CTEs are really a good place to start but the more knowledge you gain the more you tend to move away from them and use subqueries

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

      Congrats on your learning Larry. Like all tools, CTEs, subqueries and cursors all have their appropriate use cases. While it is true that you could program almost everything using subqueries, other methods (such as CTEs) could be used as well to make your code easier to follow for those coming behind you to maintain it. Like a painting, everyone has their own style and choice of tools 😉

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

    3:29 is the main purpose of CTE : OPTIMISATION
    An EXPLAIN of both syntaxe would have revealed it.
    Over code simplification, when you need to interprete subqueries results CTEs are way faster than subqueries since de BDD engine build the CTE result (in bdd server memory not cloud lol) ONCE en start with it for interpretation.

  • @Lashistoriasdelilith
    @Lashistoriasdelilith 10 дней назад

    I don't understand what the ctdorders have inside...

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

    and, boom!

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

    why did you use "using" in your join statement and not "on"?

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

    You have a crypto channel too?! I have seen your YF vids

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

    Why the pc screen is so blurred?

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

    I didn't think CTE's are stored anywhere... temp tables are

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

    I don't see the point of using WITH for a single query. If you would use the same WITH for multiple queries, I can understand how it helps.

  • @christiangrundemann9843
    @christiangrundemann9843 3 года назад

    why no disclaimer to be careful/avoid using temp tables

    • @paradix847
      @paradix847 3 года назад

      Could you elaborate on why one should be careful using temp tables?

    • @christiangrundemann9843
      @christiangrundemann9843 3 года назад +1

      @@paradix847 scope, memory and performance issues. if a temp table isn’t dropped and the client makes another request to the server, the temp table that was not disposed correctly can throw ambiguous errors

    • @paradix847
      @paradix847 3 года назад

      @@christiangrundemann9843 Hey that's good to have in mind. Thanks for the explanation.

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

      Cte isn't tepm table. It works like a temp table. That's what I know. So no disclaimer.

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

    Can I pass list of acctnumbers in with and it will traverse through each one of them to fetch acctid from diff table

  • @lightoficeberg
    @lightoficeberg 3 года назад

    Thanks! That was very helpful :)