A Common Table Expression (CTE) is a temporary result set that is defined within the execution scope of a single SELECT, INSERT, UPDATE, DELETE, or CREATE VIEW statement.

- Stackoverflow.com Wiki
2 articles, 0 books.

Common Table Expression (CTE) is a bit of a misnomer because it's not a table but rather a query. It straightforward to declare and easy to use with another queries. If you're not familiar with CTE this is worth a quick look.

CTEs are persisted temporary data sets, that allow you to store a single query to go back to later in your script. They're underrated compared to the subquery, that seems to be what most analysts around me use. Here's why I prefer to use CTEs when building SQL queries.