A couple of jobs ago, I worked at a company that did a ton of SQL and we used right justified keywords, which looks like:
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
Initially it seemed weird to see the ragged left edge, but over time I got used to it and grew to prefer it. It doesn't really hold up for extremely complex queries with lots of subqueries because everything tends to start drifting too far to the right (unrealistic example below): select *
from blah b
where b.whatever in (
select blah
from c
where c.whatever = in (
select blah
from d
where d.whatever = 'foo'
)
)
I almost never see this style used these days, and I was curious if anyone else does it this way?