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