Like following?CREATE TABLE #SOURCE ( level int not null, time_from datetime not null, time_to datetime not null, fee_amount int not null);INSERT INTO #SOURCE VALUES (1, '09:00:00', '11:00:00', 5), (1, '13:00:00', '14:00:00', 5), (2, '08:00:00', '16:00:00', 6), (4, '08:00:00', '16:00:00', 3);SELECT *FROM #SOURCE;WITH TIMEFROM AS ( SELECT time_from FROM #SOURCE UNION SELECT time_to FROM #SOURCE),TIMETO AS ( SELECT time_to FROM #SOURCE UNION SELECT time_from FROM #SOURCE)SELECT level, time_from, time_to, fee_amountFROM ( SELECT ROW_NUMBER() OVER( PARTITION BY TIMEFROM.time_from ORDER BY #SOURCE.level) ROWNUM, #SOURCE.level, #SOURCE.fee_amount, TIMEFROM.time_from, MIN(TIMETO.time_to) OVER( PARTITION BY TIMEFROM.time_from) time_to FROM TIMEFROM INNER JOIN TIMETO ON TIMEFROM.time_from < TIMETO.time_to INNER JOIN #SOURCE ON #SOURCE.time_from <= TIMEFROM.time_from AND TIMETO.time_to <= #SOURCE.time_to ) TBLWHERE ROWNUM = 1ORDER BY level, time_fromDROP TABLE #SOURCE
-------------------------------------From JapanSorry, my English ability is limited.