4 ms·
The biggest SQL antipattern is failing to recognize that SQL is actually a programming language. Therefore you should create a consistent indentation style for
by btilly 1y ago
The biggest SQL antipattern is failing to recognize that SQL is actually a programming language.
Therefore you should create a consistent indentation style for SQL. See https://bentilly.blogspot.com/2011/02/sql-formatting-style.html https://bentilly.blogspot.com/2011/02/sql-formatting-style.h... for mine. Second, you should try to group logical things together. This is why people should move subqueries into common table expressions. And finally, don't be afraid of commenting wisely.
- xyzzy_plugh 1y agoStyle opinions are borderline irrelevant without appropriate linters.
- javcasas 1y agoGo and use Google BigQuery auto-formatter in a complex query with CASE and EXTRACT YEAR FROM date, and you will have a totally different opinion. How that auto-formatter indents is borderly almost a hate crime. A thousand times better to indent manually.
- OscarCunningham 1y agoI've even seen the BigQuery formatter change the behaviour of a query, by mixing a keyword from a comment into the real code.