Tallan's Blog

Tallan’s Experts Share Their Knowledge on Technology, Trends and Solutions to Business Challenges

Posts Tagged "TSql"

The SQL Server OVER Clause

One useful feature in SQL Server is something called the OVER clause. The OVER clause has been available since SQL Server 2005 and allows you to perform window functions over a set of data.  SQL Server provides two types of window functions: aggregate window functions and ranking window functions.  I will explain what aggregate and ranking window functions are below.  The Adventure Works sample database for SQL Server 2008 R2 will be used for all examples. This database models a retail store that sells biking products. Some may want to review the schema for Adventure works, located here, for better understanding.
Aggregate Window Functions
If you have used SQL‘s GROUP BY clause, then you are probably familiar with aggregates.  Aggregate functions allow you to perform a calculation over a set of data records. Each product sold by Adventure Works belongs to a…