Skip to content

re: SQL 201: Why you should use SQL CTEs VIEW POST


As a SQL Developer I always use CTE's if I need to work with 3 or more filtered datasets. They are more readable then subqueries but more importantly they are still understandable 3 months later, or 3 years later. They are also much easier to debug than a subquery, easier to repurpose when you want to chase down a possible insight in the data, and help cut down on skewed result sets and aggregations.

I wouldn't necessarily recommend them for line of business queries that live in the backend of an application since they aren't as common to a web dev for example. Use the tools with the most intuitive familiarity in the backend. But when we're talking about reporting applications that pull data from a data warehouse CTE's can be a much better easier to sustain query writing option across data professionals.

code of conduct - report abuse