	Select
		roundtime,Dumpers_jam,Inbound_jam,Runout_jam,Sorter_Recirc_jam,Sorter_jam
			
	FROM
        
		(Select
		
		  SUM(jam_area.jam_ulgl = 1) AS Dumpers_jam,
		  SUM(jam_area.Inbound_jam = 1) AS Inbound_jam,
		  SUM(jam_area.Runout_jam = 1) AS Runout_jam,
		  SUM(jam_area.Sorter_recirc = 1) AS Sorter_Recirc_jam,
		  SUM(jam_area.Sorter_jam = 1) AS Sorter_jam,
		  FROM_UNIXTIME(CEIL(UNIX_TIMESTAMP(jam_area.t_stamp) / 600) * 600) roundtime
        
		FROM jam_area
		Where (jam_area.t_stamp BETWEEN :starttime AND :endtime)
	
		Group BY FROM_UNIXTIME(CEIL(UNIX_TIMESTAMP(jam_area.t_stamp) / 600) * 600)
		Order By jam_area.t_stamp ASC
		) okeyjam