WITH LANES AS (
	SELECT
		MIN(s04_timestamp) AS start_timestamp,
		MAX(s04_timestamp) AS end_timestamp,
        3600/TIMESTAMPDIFF(SECOND, :startDate, :endDate) AS pph_multiplier,
		sorter,
        destination_act AS lane,
		COUNT(*) AS total
	FROM package_history
	WHERE s04_timestamp BETWEEN :startDate AND :endDate
	GROUP BY sorter, s04_act_dest
    ORDER BY sorter, s04_act_dest
)
SELECT
	start_timestamp,
	end_timestamp,
    sorter,
    lane,
	/* Counts: */
	total AS total_count,
	/* PPH: */
	ROUND(total*pph_multiplier) AS total_pph,
	/* Percents: */
	ROUND(total/total, 4) AS total_percent
FROM LANES;