WINDOW FUNCTION

Example: Running Total

SELECT ct.CustomerTransactionID,
       ct.TransactionDate,
       ct.TransactionAmount,
       SUM(ct.TransactionAmount) OVER(PARTITION BY DATEPART(MONTH, TransactionDate)
       ORDER BY ct.TransactionDate) [RunningTotalByMonth]
FROM sales.CustomerTransactions ct
WHERE ct.TransactionDate BETWEEN '2013-01-01' AND '2013-12-31'
      AND customerid = 808
      AND ct.TransactionTypeID = 1
ORDER BY ct.TransactionDate;