SQL WITH Statements (Common Table Expressions - CTE)

  Рет қаралды 94,842

Becoming a Data Scientist

Becoming a Data Scientist

4 жыл бұрын

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:

Пікірлер: 77
@lalifali8426
@lalifali8426 3 жыл бұрын
You explained it so well and fast I'm now fully prepared for what may come
@vikrantyoung4868
@vikrantyoung4868 2 жыл бұрын
Simple and easy to understand explanation. It really made understanding the WITH statement so simpler. Thanks much.
@roodyg5352
@roodyg5352 5 ай бұрын
Thank you! This video helped me understand CTEs a little bit better.
@jude3026
@jude3026 3 жыл бұрын
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!
@atothezeezee
@atothezeezee 4 жыл бұрын
This was excellent - thank you.
@Tushelek
@Tushelek Жыл бұрын
Thanks, mate! Your explanation is very easy to understand.
@jundolor4013
@jundolor4013 2 жыл бұрын
Great video! This helped me run a complex query at work. Thanks 😀
@RodrigoCruz-iz3kb
@RodrigoCruz-iz3kb 3 жыл бұрын
Your video helped me a lot, thank You my friend!
@Findawaytomak3it
@Findawaytomak3it 4 ай бұрын
Dude! thank you for taking the time to break down cte's simplified (subquery >> cte). Bro, you rock!!! 😎🤟
@snipezu805
@snipezu805 2 жыл бұрын
Thanks, easy and straight forward!
@ericsims3368
@ericsims3368 3 жыл бұрын
Super helpful - thanks a bunch!
@manideepgupta2433
@manideepgupta2433 3 жыл бұрын
Finally!! Whoa! Thanks man.
@jasonwalker4155
@jasonwalker4155 3 жыл бұрын
ahhh That makes it much clearer. Thank you!
@zhiyizhang9102
@zhiyizhang9102 3 жыл бұрын
great example and explanation!
@danielmejia8530
@danielmejia8530 3 жыл бұрын
Nice man! subscribing.... Greetings from Colombia!
@josemarino4270
@josemarino4270 2 жыл бұрын
Sweet and simple: thanks!
@ukaszk.8305
@ukaszk.8305 3 жыл бұрын
You are a sensation! Please, keep going :)
@gomojo1024
@gomojo1024 10 ай бұрын
Thanks! Liked, Commented and Subscribed!
@amberjones6191
@amberjones6191 3 жыл бұрын
That was super helpful!
@marcinbednarz9488
@marcinbednarz9488 2 жыл бұрын
Hi Nathan, thanks for explaining me CTE Objects. It's know very clear to me. Appriciate
@daniellakshan
@daniellakshan 4 жыл бұрын
thanks bro, you saved a lot of time
@amare_._
@amare_._ 3 жыл бұрын
This is clearer than my textbook explanation lol thanks for the video!
@higiniofuentes2551
@higiniofuentes2551 2 жыл бұрын
Thank you for this very useful video!
@oualidben5660
@oualidben5660 3 жыл бұрын
Very clear, Thank You Sir !
@user-dc7oj3el7o
@user-dc7oj3el7o Жыл бұрын
Best explanation ever!! 👍
@user-bx8ow4xg6h
@user-bx8ow4xg6h 2 ай бұрын
Thanks a lot for simple explanation
@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.
@hereandnow8578
@hereandnow8578 3 жыл бұрын
clear and concise. ty
@ghinwamoujaes9059
@ghinwamoujaes9059 3 жыл бұрын
This is great!
@123arskas
@123arskas 5 күн бұрын
Thank you. It was wonderful explanation
@mikesizemore5939
@mikesizemore5939 2 жыл бұрын
Great video!
@moisefonguendegue5078
@moisefonguendegue5078 3 жыл бұрын
Good explanation. God bless you. AMEN.
@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.
@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.
@shujaatali4728
@shujaatali4728 2 жыл бұрын
Nice video, thank you
@alexg97343
@alexg97343 Жыл бұрын
Great explanation
@vitalykolesov9434
@vitalykolesov9434 3 жыл бұрын
Hvala puno!
@factorise001
@factorise001 2 жыл бұрын
hats off!!
@BilalAli-gr3ry
@BilalAli-gr3ry Жыл бұрын
Very helpful..... Love from India
@alecdelu83
@alecdelu83 3 жыл бұрын
Thanks!
@soseofficial3923
@soseofficial3923 2 жыл бұрын
thankyou sir, it really helped me.
@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
@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?
@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
@tamaramattson4768
@tamaramattson4768 2 ай бұрын
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
@yeoshuabenzaken7736
@yeoshuabenzaken7736 6 ай бұрын
in the 3rd example nothing changed when you joined another cte. So why did you join them?
@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 😉
@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.
@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 Жыл бұрын
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
@Lashistoriasdelilith
@Lashistoriasdelilith 29 күн бұрын
I don't understand what the ctdorders have inside...
@smz3610
@smz3610 2 жыл бұрын
You have a crypto channel too?! I have seen your YF vids
@sheenabian9368
@sheenabian9368 Жыл бұрын
and, boom!
@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.
@VeronicaAngryPolak
@VeronicaAngryPolak Жыл бұрын
why did you use "using" in your join statement and not "on"?
@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
@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 жыл бұрын
@@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.
@adridesu1
@adridesu1 5 ай бұрын
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.
@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 :)
Writing CASE WHEN Statements in SQL (IF/THEN)
5:50
Becoming a Data Scientist
Рет қаралды 85 М.
How to do Subqueries in SQL with Examples
8:20
Becoming a Data Scientist
Рет қаралды 165 М.
Who has won ?? 😀 #shortvideo #lizzyisaeva
00:24
Lizzy Isaeva
Рет қаралды 64 МЛН
WHAT’S THAT?
00:27
Natan por Aí
Рет қаралды 13 МЛН
НРАВИТСЯ ЭТОТ ФОРМАТ??
00:37
МЯТНАЯ ФАНТА
Рет қаралды 2,6 МЛН
Advanced Aggregate Functions in SQL (GROUP BY, HAVING vs. WHERE)
6:00
Becoming a Data Scientist
Рет қаралды 238 М.
SQL CTEs (Common Table Expressions) - Why and How to Use Them
7:56
Database Star
Рет қаралды 28 М.
SQL Index |¦| Indexes in SQL |¦| Database Index
9:57
Socratica
Рет қаралды 610 М.
Learn GROUP BY vs PARTITION BY in SQL
14:03
Anthony Smoak
Рет қаралды 34 М.
Complex SQL Breakdown (CTEs, Subquery, and More)
22:14
Database Star
Рет қаралды 3,2 М.
How to use the DATE_TRUNC Function in SQL (vs. TO_CHAR)
7:24
Becoming a Data Scientist
Рет қаралды 22 М.
Как правильно выключать звук на телефоне?
0:17
Люди.Идеи, общественная организация
Рет қаралды 1,8 МЛН
Смартфон УЛУЧШАЕТ ЗРЕНИЕ!?
0:41
ÉЖИ АКСЁНОВ
Рет қаралды 1,2 МЛН
Какой ноутбук взять для учёбы? #msi #rtx4090 #laptop #юмор #игровой #apple #shorts
0:18
Самый тонкий смартфон в мире!
0:55
Не шарю!
Рет қаралды 91 М.