I WANT SELECT DAYS IN MONTHS AND COUNT IN FOUR TIME RANGES GROUP BY DAYS : The problem is with range 'THREE', to count from 10 pm till 06 am next day, result to be in previous day, i have this query who give me wrong data report,
any solutions please.

   

    select TRUNC (A.time)+06/24,
	count (distinct B.code)as FOUR,
    count(case when to_char(A.time,'HH24:MI:SS') between '06:00:00'
    and  '14:00:00' then A.sn end) as ONE,
    count(case when to_char(A.time,'HH24:MI:SS') between '14:00:00'
    and '22:00:00' then A.sn end) as TWO,
    count(case  when A.time between TO_DATE ('10:00:00 PM', 'hh:mi:ss AM')
    and TO_DATE ('10:00:00 PM', 'hh:mi:ss AM')+6/24 then A.sn end) as THREE
    from B inner join A on B.bol_id = A.bol_id
    where B.group = '9' and A.time between '01-JUN-18 06:00:00' and '25-JUN-18 06:00:00' GROUP BY TRUNC (A.time)
i want structure be like this [example][1]

   


  [1]: https://i.stack.imgur.com/mxbu6.png