select
t1.col1,
t2.col2,
t3.col3
from table1 t1
join table2 t2 on t1.col2 = t2.col1
join table3 t3 on
t1.col3 = t3.col1 and
t3.col2 = something_else
where
t1.col1 > 0 and
t2.col2 <> t1.col4
order by col2
limit 100
So:1. SQL capitalization is not sacred. I lowercase everything.
2. I just indent subclauses, with four spaces, like I indent other languages. I don't go out of my way to line up things vertically.
3. Conjunctions like "and" are put at the end of a line, like a comma, not at the beginning. I think it lines things up better vertically.
4. I try to keep lines short, but I also try to keep it from getting needlessly long vertically. So if the statement is short and simple, I might fold some things back onto one line, like:
select col1, col2, col3
from table1
where col1 = something_or_other
or even: select * from table1 where col1 = something