Category Archives: T-SQL

How to Use a Window Aggregate in an Aggregate Query

A window aggregate function is an easy way to perform an aggregate calculation without changing the query to an aggregate query. This means that you can calculate an aggregate over the entire dataset while keeping the detail in the results. … Continue reading

Posted in T-SQL, T-SQL Window Functions | Leave a comment

How to use PIVOT

I recently explained how to write a PIVOT query to a group of new T-SQL developers. I have to admit that the syntax is complicated enough, and I use PIVOT infrequently enough, that I always have to look up how … Continue reading

Posted in T-SQL | Leave a comment

When should I use a stored proc and when should I use a view?

I taught an Introduction to T-SQL class this week in Colorado. It was such a great week teaching and was probably the best group of students I have ever taught. There were lots of questions, and I realized that several would … Continue reading

Posted in T-SQL | Leave a comment