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,
	concat(round(COUNT(*)/COUNT(*) * 100,2),'%') AS Total_count,
	concat(round(SUM(alltable.ACTUAL_DEST <> 'S03999')/COUNT(*) * 100,2),'%') AS Diverted,
	concat(round(SUM(alltable.DivertStatus = 14)/COUNT(*) * 100,2),'%') AS DivertFail,
	concat(round(SUM(alltable.DivertStatus = 5)/COUNT(*) * 100,2),'%') AS DestinationFull,
	concat(round(SUM(alltable.DivertStatus = 6)/COUNT(*) * 100,2),'%') AS DestinationJam,
	concat(round(SUM(alltable.DivertStatus = 12)/COUNT(*) * 100,2),'%') AS DestinationDisabled,
	concat(round(SUM(alltable.DivertStatus = 6)/COUNT(*) * 100,2),'%') as DestinationFault,
	concat(round(SUM(alltable.DivertStatus = 17)/COUNT(*) * 100,2),'%') as Lost,
	concat(round(SUM(alltable.DivertStatus = 21)/COUNT(*) * 100,2),'%') as Unsafe,
	concat(round(SUM(alltable.DivertStatus = 18)/COUNT(*) * 100,2),'%') as DimError,
	concat(round(SUM(alltable.DivertStatus = 4)/COUNT(*) * 100,2),'%') as GapError,
	concat(round(SUM(alltable.DivertStatus = 1)/COUNT(*) * 100,2),'%') as Unknown	
FROM alltable
Where (alltable.DEST_REQ = :lane AND alltable.t_stamp BETWEEN :starttime AND :endtime)
GROUP BY hour(alltable.t_stamp)