SQL WITH Statements (Common Table Expressions - CTE)

  Рет қаралды 98,783

Becoming a Data Scientist

Becoming a Data Scientist

Күн бұрын

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:
2) DataCamp:
3) Udacity:

Пікірлер: 78
@roodyg5352
@roodyg5352 8 ай бұрын
Thank you! This video helped me understand CTEs a little bit better.
@Findawaytomak3it
@Findawaytomak3it 7 ай бұрын
Dude! thank you for taking the time to break down cte's simplified (subquery >> cte). Bro, you rock!!! 😎🤟
@meanpillscasper
@meanpillscasper 2 жыл бұрын
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.
@lalifali8426
@lalifali8426 3 жыл бұрын
You explained it so well and fast I'm now fully prepared for what may come
@jude3026
@jude3026 4 жыл бұрын
U ROCK. im going through your channel and god you couldnt get less helpful. thanks man
@atothezeezee
@atothezeezee 4 жыл бұрын
This was excellent - thank you.
@vikrantyoung4868
@vikrantyoung4868 3 жыл бұрын
Simple and easy to understand explanation. It really made understanding the WITH statement so simpler. Thanks much.
@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.
@amare_._
@amare_._ 3 жыл бұрын
This is clearer than my textbook explanation lol thanks for the video!
@Tushelek
@Tushelek Жыл бұрын
Thanks, mate! Your explanation is very easy to understand.
@salsaica2
@salsaica2 2 жыл бұрын
Thank you for the video, very clear, I like the format, it's straightforward and very well explained!
@waldojams
@waldojams 3 жыл бұрын
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.
@marcinbednarz9488
@marcinbednarz9488 2 жыл бұрын
Hi Nathan, thanks for explaining me CTE Objects. It's know very clear to me. Appriciate
@송예은-h7b
@송예은-h7b Жыл бұрын
Best explanation ever!! 👍
@alexg97343
@alexg97343 2 жыл бұрын
Great explanation
@123arskas
@123arskas 2 ай бұрын
Thank you. It was wonderful explanation
@BilalAli-gr3ry
@BilalAli-gr3ry Жыл бұрын
Very helpful..... Love from India
@ViraSpasivska
@ViraSpasivska 5 ай бұрын
Thanks a lot for simple explanation
@higiniofuentes2551
@higiniofuentes2551 2 жыл бұрын
Thank you for this very useful video!
@tauseef_khawaja
@tauseef_khawaja Жыл бұрын
conceptual and easy way to describe
@snipezu805
@snipezu805 2 жыл бұрын
Thanks, easy and straight forward!
@jundolor4013
@jundolor4013 2 жыл бұрын
Great video! This helped me run a complex query at work. Thanks 😀
@gomojo1024
@gomojo1024 Жыл бұрын
Thanks! Liked, Commented and Subscribed!
@RodrigoCruz-iz3kb
@RodrigoCruz-iz3kb 4 жыл бұрын
Your video helped me a lot, thank You my friend!
@yeoshuabenzaken7736
@yeoshuabenzaken7736 9 ай бұрын
in the 3rd example nothing changed when you joined another cte. So why did you join them?
@ukaszk.8305
@ukaszk.8305 3 жыл бұрын
You are a sensation! Please, keep going :)
@tamaramattson4768
@tamaramattson4768 5 ай бұрын
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
@danielmejia8530
@danielmejia8530 4 жыл бұрын
Nice man! subscribing.... Greetings from Colombia!
@jilliansolomon1178
@jilliansolomon1178 3 жыл бұрын
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
@VeronicaAngryPolak
@VeronicaAngryPolak Жыл бұрын
why did you use "using" in your join statement and not "on"?
@josemarino4270
@josemarino4270 2 жыл бұрын
Sweet and simple: thanks!
@Lashistoriasdelilith
@Lashistoriasdelilith 3 ай бұрын
I don't understand what the ctdorders have inside...
@hasanmougharbel8030
@hasanmougharbel8030 2 жыл бұрын
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 Жыл бұрын
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
@zhiyizhang9102
@zhiyizhang9102 4 жыл бұрын
great example and explanation!
@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?
@TheBeanzo
@TheBeanzo 3 жыл бұрын
ahhh That makes it much clearer. Thank you!
@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 😉
@daniellakshan
@daniellakshan 4 жыл бұрын
thanks bro, you saved a lot of time
@shujaatali4728
@shujaatali4728 2 жыл бұрын
Nice video, thank you
@amberjones6191
@amberjones6191 3 жыл бұрын
That was super helpful!
@mikesizemore5939
@mikesizemore5939 2 жыл бұрын
Great video!
@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.
@hereandnow8578
@hereandnow8578 3 жыл бұрын
clear and concise. ty
@moisefonguendegue5078
@moisefonguendegue5078 4 жыл бұрын
Good explanation. God bless you. AMEN.
@smz3610
@smz3610 2 жыл бұрын
You have a crypto channel too?! I have seen your YF vids
@ericsims3368
@ericsims3368 3 жыл бұрын
Super helpful - thanks a bunch!
@soseofficial3923
@soseofficial3923 2 жыл бұрын
thankyou sir, it really helped me.
@lightoficeberg
@lightoficeberg 3 жыл бұрын
Thanks! That was very helpful :)
@manideepgupta2433
@manideepgupta2433 3 жыл бұрын
Finally!! Whoa! Thanks man.
@oualidben5660
@oualidben5660 3 жыл бұрын
Very clear, Thank You Sir !
@meshari_27
@meshari_27 2 ай бұрын
Thank you
@hari7027
@hari7027 5 ай бұрын
Can I pass list of acctnumbers in with and it will traverse through each one of them to fetch acctid from diff table
@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.
@TheCazz10
@TheCazz10 2 жыл бұрын
I didn't think CTE's are stored anywhere... temp tables are
@ghinwamoujaes9059
@ghinwamoujaes9059 3 жыл бұрын
This is great!
@superfreiheit1
@superfreiheit1 3 жыл бұрын
Why the pc screen is so blurred?
@vitalykolesov9434
@vitalykolesov9434 3 жыл бұрын
Hvala puno!
@factorise001
@factorise001 2 жыл бұрын
hats off!!
@deepakms5918
@deepakms5918 3 жыл бұрын
Super sir 👍👍👍
@alecdelu83
@alecdelu83 3 жыл бұрын
Thanks!
@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
@adridesu1
@adridesu1 8 ай бұрын
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 4 жыл бұрын
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 жыл бұрын
@@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 2 жыл бұрын
Cte isn't tepm table. It works like a temp table. That's what I know. So no disclaimer.
@sheenabian9368
@sheenabian9368 Жыл бұрын
and, boom!
Writing CASE WHEN Statements in SQL (IF/THEN)
5:50
Becoming a Data Scientist
Рет қаралды 89 М.
How to do Subqueries in SQL with Examples
8:20
Becoming a Data Scientist
Рет қаралды 171 М.
إخفاء الطعام سرًا تحت الطاولة للتناول لاحقًا 😏🍽️
00:28
حرف إبداعية للمنزل في 5 دقائق
Рет қаралды 78 МЛН
pumpkins #shorts
00:39
Mr DegrEE
Рет қаралды 109 МЛН
SQL CTEs (Common Table Expressions) - Why and How to Use Them
7:56
Database Star
Рет қаралды 33 М.
Advanced SQL Tutorial | CTE (Common Table Expression)
3:44
Alex The Analyst
Рет қаралды 352 М.
Advanced Aggregate Functions in SQL (GROUP BY, HAVING vs. WHERE)
6:00
Becoming a Data Scientist
Рет қаралды 254 М.
إخفاء الطعام سرًا تحت الطاولة للتناول لاحقًا 😏🍽️
00:28
حرف إبداعية للمنزل في 5 دقائق
Рет қаралды 78 МЛН