SELECT
TAG ,
to_char(RECORDTIME,'yyyy-mm-dd HH24:MI:SS'),
to_number(RECORDVALUE )
FROM HSE.BA_COLLECTIONDATA
WHERE TAG IN( 'FAR13_5710_FT-30103' )
AND to_char(RECORDTIME,'yyyy-mm-dd HH24:MI:SS') >='2022-01-05'
AND to_char(RECORDTIME,'yyyy-mm-dd HH24:MI:SS') <='2022-01-06'
and substr(to_char(RECORDTIME,'YYYY-MM-DD HH24:MI:SS'),15,20)='00:00'
ORDER BY RECORDTIME DESC
select t.* from (
select '2021-01-01 15:15:00' as dtime from dual
union all
select '2021-01-02 08:00:00' as dtime from dual
union all
select '2021-01-01 08:00:00' as dtime from dual
union all
select '2021-01-06 08:00:00' as dtime from dual
)t
where 1=1
and t.dtime>='2021-01-01'
and t.dtime<'2021-01-03'
and substr(to_char(to_date(t.dtime,'YYYY-MM-DD HH24:MI:SS'),'YYYY-MM-DD HH24:MI:SS'),15,20)='00:00'