I discovered a powerful approach to help you building a SQL model

But it needs you to stretch your mind and think differently than before.

Thinking backwards is not something new. In software development “test driven development” is basically thinking backwards. You write a test for your final excepted behaviour and then you work against it. 

Claire from dbt sketched out a similar approach in their discourse community.

– 🎰 Sketch your final report you would like to end up with – I saw this approach also in SQL courses for interview questions and I already use this pretty often when I work on a complex model

– 🍄 Mock the query that would produce the table – I struggle with mocking, also in test driven dev. And I can’t explain why – but I am working on it since it really helps to structure and develop a plan

🍥 Iterate on the mock – Filling more an more gaps with real information

🎾 Have a real query in the end

The mock and pseudo part is where I still struggle but I guess it needs some training. I plan to work on my next models this way.

What are your thoughts? Do you work like this already?

I post my analytics & data thoughts every morning. Don’t miss the good ones and just follow me. I promise I always follow back.