SELECT 
  concat(date(alltable.t_stamp), ' ', hour(alltable.t_stamp), ':00') AS StartTimestamp,
  concat('H', TIMESTAMPDIFF(HOUR, DATE_FORMAT(alltable.t_stamp,"%Y-%m-%d %H:00:00"), DATE_FORMAT(now(),"%Y-%m-%d %H:00:00"))) AS Hour,
  COUNT(*) AS Total_count
FROM alltable
WHERE alltable.t_stamp BETWEEN :starttime AND :endtime
GROUP BY date(alltable.t_stamp), hour(alltable.t_stamp)
