WITH GAYLORDS AS (
	SELECT
		MIN(timestamp) AS start_timestamp,
		MAX(timestamp) AS end_timestamp,
        3600/TIMESTAMPDIFF(SECOND, :startDate, :endDate) AS pph_multiplier,
		gaylord_id AS gaylord,
		SUM(count) AS total
	FROM gl_history
	WHERE timestamp BETWEEN :startDate AND :endDate
	GROUP BY gaylord_id
    ORDER BY gaylord_id
)
SELECT
	start_timestamp,
	end_timestamp,
    gaylord,
	/* Counts: */
	total AS total_count,
	/* PPH: */
	ROUND(total*pph_multiplier) AS total_pph,
	/* Percents: */
	ROUND(total/total, 4) AS total_percent
FROM GAYLORDS;