퇴근5분전

 

sqler에 질문글..

http://www.sqler.com/bSQLQA/862019

 

심심해서....  

 

 

;with tmp
as
(
select *
from
(
    values 
        (1,         '2008-01-02 00:00:00.000' ),
        (2,          NULL),
        (3,          NULL),
        (4,          '2008-01-03 00:00:00.000'),
        (5,          NULL),
        (6,          NULL),
        (7,          NULL),
        (8,          NULL),
        (9,          '2008-01-04 00:00:00.000'),
        (10,         NULL),
        (11,         NULL)
) as tb (a, b )
)

select a, isnull( b , ( select max( b ) from tmp where a < bs.a )) as bb
from tmp as bs