B:BD[
4.466] → [
4.466:770]
lower(open) = 0 and exists(
select 1
from store_time
where
store_time.store_id = store.store_id and
upper(open) = 10080
) as wow,
open
from store_time
where store_time.store_id = store.store_id
) as t
group by x
order by x asc
) as y),
coalesce(wow, lower(open) / 1440) as x,
array_agg(array[lower(open), upper(open)] order by case
when wow is not null then 2147483647
else lower(open)
end asc)
from (
select
case when lower(open) = 0 then (
select lower(open) / 1440
from store_time
where
store_time.store_id = store.store_id and
upper(open) = 10080
) end as wow,
open
from store_time
where store_time.store_id = store.store_id
) as t
group by x
) as y full join (
select generate_series
from generate_series(0,6)
) as ayy on y.x = ayy.generate_series
),