Divide and Conquer with Subquery Factoring
Kim Berg Hansen · Apress eBooks · 2020
Every programmer has at some point learned about modularization – splitting the code into smaller units each solving a distinct part of the whole, typically used in procedural languages as functions and procedures, like in PL/SQL. In SQL there are views to help reduce complexity and provide reusability. But you can also modularize in a local scope, for example, in PL/SQL you can create local functions and procedures in the declaraction section. In SQL there is a similar mechanism called subquery factoring, also commonly known as the with clause or sometimes common table expressions, statement scoped views, or named query blocks (just to mention some of the terms used for this).