Leslie Vail has a couple of new posts looking at SQL 2012. She starts with T-SQL 2012: LAG & LEAD.
Dynamics Confessions Blogspot: T-SQL 2012: LAG & LEAD
Archived post from 2013. Dynamics GP and the links it points to have changed since; check current documentation before relying on version-specific steps.