Maintainable SQL makes its assumptions visible. Use clear names, keep transformations in logical stages, and avoid repeating business rules in multiple queries.
Separate source cleanup from business logic. That makes it easier to test each layer and identify whether a problem began in the data or in the analysis.
Add simple checks for row counts, uniqueness, and accepted values. A query that runs successfully can still produce the wrong result, so correctness needs explicit tests.