Refactoring legacy SQL to dbt | dbt Developer Hub
This guide walks through refactoring a long SQL query (perhaps from a stored procedure) into modular dbt data models.