Formatting Long SQL Queries

I recently joined a local offline holivor on the topic of formatting long SQL queries.

Actually, the entire holivor comes down to the fact that it is more convenient to read - INNER JOIN BEFORE the table, or AFTER it, and also - AND - before or after the condition is declared.

Two options and a question for the Khabrovites under the cut:


Option 1:


SELECT
t.field,
t.field1,
...
FROM
table t INNER JOIN
table1 t1 ON t1.id = t.id INNER JOIN
table2 t2 ON t2.id=t1.id
WHERE
t.value = 'foo' AND
t1.value = 'bar'
GROUP BY t.field
ORDER BY t.field


Option 2:


SELECT
t.field,
t.field1,
...
FROM table t
INNER JOIN table1 t1
ON t1.id=t.id
INNER JOIN table2 t2
ON t2.id=t1.id
WHERE t.value='foo'
AND t1.value='bar'
GROUP BY t.field
ORDER BY t.field


We can’t find standards for formatting queries — for programming — completely, for queries — no. And still argue.

What do you say, which option do you use? First or second? Or maybe the third?