CREATE TABLE temp_trd_shr
(
fromtime VARCHAR2(5)
, totime VARCHAR2(5)
);
INSERT INTO temp_trd_shr VALUES ('01:00', '18:00');
INSERT INTO temp_trd_shr VALUES ('02:00', '17:00');
INSERT INTO temp_trd_shr VALUES ('03:00', '16:00');
INSERT INTO temp_trd_shr VALUES ('04:00', '15:00');
INSERT INTO temp_trd_shr VALUES ('05:00', '14:00');
INSERT INTO temp_trd_shr VALUES ('06:00', '13:00');
INSERT INTO temp_trd_shr VALUES ('08:30', '09:30');
INSERT INTO temp_trd_shr VALUES ('08:45', '09:45');
SELECT COUNT(*)
FROM temp_trd_shr;
-- 8
SELECT *
FROM temp_trd_shr
WHERE TO_NUMBER(REPLACE(fromtime, ':')) <= TO_NUMBER(REPLACE('08:00', ':'))
AND TO_NUMBER(REPLACE(totime, ':')) >= TO_NUMBER(REPLACE('10:00', ':'))
ORDER BY
1
;
/*
01:00 18:00
02:00 17:00
03:00 16:00
04:00 15:00
05:00 14:00
06:00 13:00
*/