Hacker News new | ask | show | jobs
by erdemozg 3517 days ago
I use the following indentation pattern and find it very useful:

    select 
        t1.col1,
        t2.col1

    from 
        table1 t1 
        left join table2 t2 on t2.primarykey = t1.foreignkey

    where 
        t1.somevalue is not null
        and isnull(t2.someothervalue, 0) > 0

    order by 
        t1.someothervalue desc
By using this pattern I can easily locate columns, tables, criterias, grouping fields, orders etc. And it works well with more complicated queries as well given all the subqueries, cases etc. written in a similar fashion.