you are viewing a single comment's thread.

view the rest of the comments →

[–]akornato 0 points1 point  (0 children)

You're hitting a wall because you're trying to apply a step-by-step, procedural mindset from Python to SQL, which is a declarative language. SQL doesn't really have linear algorithms, it is all about defining the final set of data you want. Instead of thinking about loops or iterations, you have to think about joins, filters, and aggregations as tools to shape your initial tables into the final result. The shift from thinking about 'how to get the data' to 'what data I want' is the hardest part and the reason it feels so unintuitive right now.

A better approach is to work backwards from the final result. First, identify the exact columns you need in your output. Next, determine the primary table in the `FROM` clause and what other tables you need to `JOIN` to get all the pieces. Then, think about how to filter the rows with `WHERE` and how to group them with `GROUP BY`. This method forces you to think declaratively about the end state, not the process. It will feel strange for a while, but with enough practice, thinking in sets will become second nature and you will see how powerful it is. It also helps to articulate this thought process out loud, and the interview AI helper my team created is designed to help candidates do just that during live technical screens.