Applying LAG() to multiple rows with a null value
问题 Given: with m as ( select 1 ID, cast('03/01/2015' as datetime) PERIOD_START, cast('3/31/2015' as datetime) PERIOD_END union all select 1 ID, '04/01/2015', '4/28/2015' union all select 1 ID, '05/01/2015', '5/31/2015' union all select 1 ID, '06/01/2015', '06/30/2015' union all select 1 ID, '07/01/2015', '07/31/2015' ) , a as ( SELECT 1 ID, cast('2015-03-13 14:17:00.000' as datetime) AUDIT_TIME, 'READ [2]' STATUS UNION ALL SELECT 1 ID, '2015-04-27 15:51:00.000' AUDIT_TIME, 'HELD [2]' STATUS