SQL Tips and Tricks

In this somewhat opinionated list of SQL tips and tricks, the author covers a range of topics including formatting, useful features, avoiding pitfalls, and common pitfalls to be aware of. Some unique advice includes using a leading comma to separate fields in the SELECT clause for better readability, using a dummy value in the WHERE clause for dynamic conditions, and using the QUALIFY keyword to filter window functions. One controversial point the author makes is that while you can GROUP BY column position, it’s generally recommended to use column names for production code. The importance of understanding the order of execution in SQL queries and the benefits of commenting your code for future reference are also stressed. The author emphasizes the value of reading the documentation in full to avoid unexpected surprises, as illustrated by a personal example with the usage of the GREATEST function.

https://github.com/ben-n93/SQL-tips-and-tricks

To top