BNA8/.resources/8afe0f9320b1a4adbd6c1440a3eff867ab21cbc8bd240c56dbe5582dbe757665
2025-08-18 15:23:02 +04:00

25 lines
609 B
Plaintext

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;