How to write powerful SQL that's easy to maintain
summary
Starts from a real report example counting employees per department and shows refactors: use WITH clause for CTEs, collapse common joins into views, then replace views with SQL macros to parameterize thresholds and even table and column identifiers using table_t and columns_t. Explains table versus scalar macros, that macros return SQL text as a CLOB, and that macros can call macros. Demonstrates debugging with dbms_utility.expand_sql_text to reveal a copy paste bug (>= vs >) and verifies equivalence with set difference queries.
AI-written summary · about
chapters (5)
related talks
31mFuturistic SQL: Making the impossible possible
54mBecoming a SQL Guru
46mAwesome SQL – tips and tricks for application developers
57mProgramming the SQL Way with Common Table Expressions
01h 00mComplex Queries with Modern SQL
41mModern SQL: Evolution of a dinosaur
40mLevel-up Your ActiveRecord Skills: Learn SQL!
18mApparently, you can "debug" your SQL queries
