You can create SQL Macros (SQM) to factor out common SQL expressions and statements into reusable, parameterized constructs that can be used in other SQL statements. SQL macros can either be scalar expressions, typically used in
GROUP BY and
HAVING clauses, to encapsulate calculations and business logic or can be table expressions, typically used in a
SQL macros increase developer productivity, simplify collaborative development, and improve code quality.
This page provides more detailed information explaining what SQL Macros are useful for and supplying various examples to use.
These practices show how to use SQL Macro as scalar and table expressions.