как получить данные до 8:30, с 8:30 до 9:00 и после 9:00
select distinct emp.emc_name
Count(select count(max(s.SAD_DATE)) from Shift s1 where s1.EM_CODE=s.EM_CODE and EXTRACT(HOUR FROM CAST(s.SAD_DATE AS TIMESTAMP)) < 8:30 ) Before8.30am ,
Count(select count(max(s.SAD_DATE)) from Shift s1 where s1.EM_CODE=s.EM_CODE and EXTRACT(HOUR FROM CAST(s.SAD_DATE AS TIMESTAMP)) between 8:30 and 9 ) 8.30amTo9am,
Count(select count(max(s.SAD_DATE)) from Shift s1 where s1.EM_CODE=s.EM_CODE and EXTRACT(HOUR FROM CAST(s.SAD_DATE AS TIMESTAMP)) > 9 ) After9,
from Shift s,emply emp
where s.EM_CODE = emp.EM_CODE and emp.DP_CODE in ('C019') and s.SAC_INOUT=1
and s.SAD_DATE between '01-mar-2018' and '31-mar-2018'
order by emp.EMC_NAME
group by emp.EMC_NAME