あなたは注文数が水平方向に分割したい場合、すなわち、行方向。
select s.id shop_id,
concat(case when date_format(now(),'%H') > 12
then concat(date_format(now(),'%H') - 12,' PM')
else concat(date_format(now(),'%H'),' AM') end
,' - ',case when date_format(now(),'%H') + 1 > 12
then concat(date_format(now(),'%H') + 1 - 12,' PM')
else concat(date_format(now(),'%H') + 1,' AM') end) window,
count(*) orders
from orders o
left join shops s
on s.id = o.shop_id
group by s.id, window;
注文を垂直に分割する場合、つまり列単位で分割する場合は、
select s.shop_id,
count(distinct case when hour(now()) = 0 then o.order_id else 0 end) 'midnight - 1 AM',
count(distinct case when hour(now()) = 1 then o.order_id else 0 end) '1 - 2 AM',
count(distinct case when hour(now()) = 2 then o.order_id else 0 end) '2 - 3 AM',
count(distinct case when hour(now()) = 3 then o.order_id else 0 end) '3 - 4 AM',
count(distinct case when hour(now()) = 4 then o.order_id else 0 end) '4 - 5 AM',
count(distinct case when hour(now()) = 5 then o.order_id else 0 end) '5 - 6 AM',
count(distinct case when hour(now()) = 6 then o.order_id else 0 end) '6 - 7 AM',
count(distinct case when hour(now()) = 7 then o.order_id else 0 end) '7 - 8 AM',
count(distinct case when hour(now()) = 8 then o.order_id else 0 end) '8 - 9 AM',
count(distinct case when hour(now()) = 9 then o.order_id else 0 end) '9 - 10 AM',
count(distinct case when hour(now()) = 10 then o.order_id else 0 end) '10 - 11 AM',
count(distinct case when hour(now()) = 11 then o.order_id else 0 end) '11 - noon',
count(distinct case when hour(now()) = 12 then o.order_id else 0 end) 'noon - 1 PM',
count(distinct case when hour(now()) = 13 then o.order_id else 0 end) '1 - 2 PM',
count(distinct case when hour(now()) = 14 then o.order_id else 0 end) '2 - 3 PM',
count(distinct case when hour(now()) = 15 then o.order_id else 0 end) '3 - 4 PM',
count(distinct case when hour(now()) = 16 then o.order_id else 0 end) '4 - 5 PM',
count(distinct case when hour(now()) = 17 then o.order_id else 0 end) '5 - 6 PM',
count(distinct case when hour(now()) = 18 then o.order_id else 0 end) '6 - 7 PM',
count(distinct case when hour(now()) = 19 then o.order_id else 0 end) '7 - 8 PM',
count(distinct case when hour(now()) = 20 then o.order_id else 0 end) '8 - 9 PM',
count(distinct case when hour(now()) = 21 then o.order_id else 0 end) '9 - 10 PM',
count(distinct case when hour(now()) = 22 then o.order_id else 0 end) '10 - 11 PM',
count(distinct case when hour(now()) = 23 then o.order_id else 0 end) '11 PM - midnight'
from shops s inner join orders o on o.shop_id = s.shop_id;