Modularizing SQL? (2007)
The most important code management tool SQL has are views and the WITH clause.<p><a href="https:&#x2F;&#x2F;modern-sql.com&#x2F;use-case&#x2F;literate-sql" rel="nofollow">https:&#x2F;&#x2F;modern-sql.com&#x2F;use-case&#x2F;literate-sql</a><p>Something like &quot;polymorpihc&quot; views would be extremley useful, but is not there yet (in standard SQL).<p>In other areas there are sublte features like the explicit WINDOW clause to avoid repeating similar OVER clauses. Breifly mentioned at the end of this doc:<p><a href="https:&#x2F;&#x2F;www.postgresql.org&#x2F;docs&#x2F;current&#x2F;tutorial-window.html" rel="nofollow">https:&#x2F;&#x2F;www.postgresql.org&#x2F;docs&#x2F;current&#x2F;tutorial-window.html</a><p>This was adopted in recent years by many FOSS-DBs, but not yet by the big commercial ones:<p><a href="https:&#x2F;&#x2F;modern-sql.com&#x2F;static&#x2F;sm-blog-2019-postgesql-11.over.en&#x2F;T612.window-clause.zrNWMjbF.svg" rel="nofollow">https:&#x2F;&#x2F;modern-sql.com&#x2F;static&#x2F;sm-blog-2019-postgesql-11.over...</a><p>Similarily the chaining of grouping sets can be helpful in those very rare cases you need them.<p>The Oracle Database intrdouced &quot;SQL Macros&quot; recently. For my taste, they are too &#x27;rude&#x27; to make me happy on first sight (much like C #define):<p><a href="https:&#x2F;&#x2F;blog.dbi-services.com&#x2F;oracle-20c-sql-macros-a-scalar-example-to-join-agility-and-performance&#x2F;" rel="nofollow">https:&#x2F;&#x2F;blog.dbi-services.com&#x2F;oracle-20c-sql-macros-a-scalar...</a>