CODE: last_value

SELECT
CustomerID
, SalesOrderID
, CAST(OrderDate AS DATE) AS OrderDate
, TotalDue
, LAST_VALUE(TotalDue) OVER ( PARTITION BY CustomerID ORDER BY SalesOrderID ) AS TD
FROM
Sales.SalesOrderHeader
ORDER BY
CustomerID