--20021014을 기준으로 상태 변경 이전 ;with 부품상태변경이력(부품번호,상태코드,유효시작일,유효종료일,발생순번) as ( select 'cdr788', 'a', '20021012', '99991231', 5 union all select 'lcd257', 'a', '20021010', '20021012', 1 union all select 'lcd257', 'c', '20021010', '20021012', 1 union all select 'lcd257', 'e', '20021010', '20021012', 2 union all select 'lcd257', 'f', '20021010', '20021014', 3 union all select 'lcd257', 'z', '20021014', '99991231', 1 ) select * from 부품상태변경이력 where 유효시작일 < '20021014' and 유효종료일 >= '20021014' and 부품번호 = 'lcd257' --20021014을 기준으로 상태 변경 이후 ;with 부품상태변경이력(부품번호,상태코드,유효시작일,유효종료일,발생순번) as ( select 'cdr788', 'a', '20021012', '99991231', 5 union all select 'lcd257', 'a', '20021010', '20021012', 1 union all select 'lcd257', 'c', '20021010', '20021012', 1 union all select 'lcd257', 'e', '20021010', '20021012', 2 union all select 'lcd257', 'f', '20021010', '20021014', 3 union all select 'lcd257', 'z', '20021014', '99991231', 1 ) select * from 부품상태변경이력 where 유효시작일 <= '20021014' and 유효종료일 > '20021014' and 부품번호 = 'lcd257'