Before I start talking about how to write queries for complex scenarios, I want to focus on how to write good T-SQL. This is not about writing code that performs well. This is about writing T-SQL code that reads well. I want to go over how to write code so that it is easily readable to others and to yourself. If you are like me, you’ll get to a point in your career where you look at your own code and do not immediately understand all the logic involved.
Writing T-SQL that is understandable helps you and your company. Many other coding languages have standards or best practices, and I believe that ...