Best practices for writing SQL queries
This is an aside, but a colleague years back showed me his preferred method formatting SQL statements, and I&#x27;ve always found it to be the best in terms of readability, I just wish there was more automated tool support for this format. The idea is to line up the first value from each clause. Visually it makes it extremely easy to &quot;chunk&quot; the statement by clause, e.g.:<p><pre><code>  SELECT a.foo, b.bar, g.zed
    FROM alpha a
    JOIN beta b ON a.id = b.alpha_id
    LEFT JOIN gamma g ON b.id = g.beta_id
   WHERE a.val &gt; 1
     AND b.col &lt; 2
   ORDER BY a.foo</code></pre>