CTEs, Views or Temp Tables?


 

I’ve just finished watching the video from the @GuyInACube about Common Table Expressions and I noticed that in several comments there was the request to explain what is the difference between Common Table Expressions, Views and Temp Tables. This is quite a common question, and it is time to give it a simple, concise, and clear answer, once and for all. Common Table Expressions You can think of a Common Table Expression (CTE) as a table subquery. A table subquery, also sometimes referred to as derived table, is a query that is used as the starting point to build another query. Like a