SQL TUTORIAL - CTEs Part 1
HTML-код
- Опубликовано: 24 июл 2024
- A tutorial on how to write and use CTEs
How to calculate aggregations and then join to underlying base table
How to remove duplicates using CTEs
How to created nested CTEs
How to create stored procedures that contain CTEs Наука
your videos definitely should be in top of the results when people search for SQL Server tutorials
I guess I'm quite off topic but do anyone know a good site to watch new series online ?
These videos are fantastic. The only thing I would suggest is changing the zoom on your window. It would be so much nicer if the font size was increased by a factor of 2
Thanks for the feedback, it is something I have implemented in my newer videos.
Your videos are amazing. I'm currently working towards moving into a BI Developer role. I already have pretty decent SQL skills but your tutorials really fill in the gaps in some areas and your explanations are very clear.
Thanks for the feedback and good look with the new role.
These videos are awesome! Thank you!
Thanks for the feedback, much appreciated 👍
Thanks brother. Like WOW. You the man.
Thank you!
This is really useful explanation of CTEs. The only problem with removing data from my table is that I don't have a Id column so cannot use MIN(Id)
If you cannot use another column because rows are exact duplicates then you can use ROW_NUMBER() OVER(PARTITION BY ORDER BY (SELECT NULL) AS n within the CTE, this will give each duplicate a different number, you can then DELETE FROM CTE WHERE n > 1 to remove duplicates, give it a try and let me know how you get on
@@BeardedDevData Yes that does exactly what I want it to do to remove my Duplicates. Many thanks for your help.
Its weird that you cant use the same cte muliple times.
My only complaint is this; ( is NOT a bracket. At best is might be called a Round Bracket but it is an Open Parenthesis. { is a Curly Bracket or possibly a Brace. [ is a Bracket or Square Bracket. It's just too confusing to hear ( being called a Bracket.
What is the difference between a CTE and a View?
The first difference is scope, you can commonly refer to views in all queries whereas with a CTE you have to declare to it and refer to it in the same statement. If you find yourself writing the same query over and over then creating a view would save you time, the other benefit of views is that they can be used to separate the database from applications, prevent users accessing tables directly or simply rename columns to something more friendly. A typical use case for a CTE is where you need to perform multiple operations on a set of data such as if you want to find out the average of total customer spend, where first you need to calculate total spend per customer then find the average or rank data then apply a top n. Views can also be materialised, which can help speed up queries and CTEs can be used recursively to flatten hierarchies.
@@BeardedDevData thanks that helped.
is it possible to get a copy of the databases you use in your videos?
Unfortunately not, I don’t have them anymore but I am adding scripts to create the objects required in my latest videos. For ease I may consider using AdventureWorks in the future.
I managed to install Adventure Works so it would be great if you use that one. In future, could you at least say which database each video is using, please?
Also, it would be helpful if you could make clear the order we should watch all the videos say from start to finish. Would that be possible?
Sure, no problem
can you share code pls