-- Hourly Induct Graph Query (Rate)
-- Shows every hour in detail for graphing

SELECT
    CONCAT('H', TIMESTAMPDIFF(HOUR,
        DATE_FORMAT(t_stamp, "%Y-%m-%d %H:00:00"),
        DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00")
    )) AS Hour,
    COUNT(*) AS Total
FROM alltable
WHERE t_stamp BETWEEN :starttime AND :endtime
GROUP BY DATE(t_stamp), HOUR(t_stamp)
ORDER BY DATE(t_stamp) ASC, HOUR(t_stamp) ASC;

