WITH INDUCTS AS (
	SELECT
		DATE_FORMAT(MIN(timestamp), "%Y-%m-%d %H:%i:00") AS time,
		SUM(count) AS total
	FROM pe_history
	WHERE timestamp BETWEEN :startDate AND :endDate
      AND lane_id = :chute
	GROUP BY DATE_FORMAT(timestamp, "%Y-%m-%d %H:%i:00")
    ORDER BY DATE_FORMAT(timestamp, "%Y-%m-%d %H:%i:00")
)
SELECT
	time,
	/* Counts: */
	total AS total_count,
	/* PPH: */
	ROUND(total*60) AS total_pph,
	/* Percents: */
	ROUND(total/total, 4) AS total_percent
FROM INDUCTS;