Remix.run Logo
btilly 15 hours 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.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 14 hours ago | parent [-]

Style opinions are borderline irrelevant without appropriate linters.

javcasas 14 hours ago | parent [-]

Go 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 13 hours ago | parent [-]

I've even seen the BigQuery formatter change the behaviour of a query, by mixing a keyword from a comment into the real code.