As a first step, assign the bin number for each arrival.
This is the sample table I used.
VISIT_ID Surgeon Arrival
123 Dr. A -45
156 Dr. A -25
198 Dr. A 32
The query below uses a Switch expression to assign the bin number, giving me this result set.
VISIT_ID Surgeon Arrival bin_number
123 Dr. A -45 1
156 Dr. A -25 2
198 Dr. A 32 6
SELECT
o.VISIT_ID,
o.Surgeon,
o.Arrival,
Switch
(
o.Arrival <= -30, 1,
o.Arrival <= -15, 2,
o.Arrival <= 0, 3,
o.Arrival <= 15, 4,
o.Arrival <= 30, 5,
o.Arrival > 30, 6,
) AS bin_number
FROM OR_on_time_log AS o;
You can build on that with a PIVOT
to return the bin counts for each surgeon.