Select
	SorterName,InductName,Total_count,singlecarrier_count,doublecarrier_count,Startstamp,Endtstamp,
	Total_count/Total_count as Total_perc,
    singlecarrier_count/Total_count as SingleCarrier_perc,
    doublecarrier_count/Total_count as DoubleCarrier_perc,
    Total_count*3600/TIMESTAMPDIFF(second, Startstamp, Endtstamp) as Total_rate,
	singlecarrier_count*3600/TIMESTAMPDIFF(second, Startstamp, Endtstamp) as SingleCarrier_rate,
	doublecarrier_count*3600/TIMESTAMPDIFF(second, Startstamp, Endtstamp) as DoubleCarrier_rate
FROM
	(SELECT 
		  'S03' as SorterName,
		  'Induct 1' as InductName,
		  COUNT(*) AS Total_count,
		  SUM(alltable.ParcelHistory_TupelLength = 1) AS singlecarrier_count,
 		  SUM(alltable.ParcelHistory_TupelLength = 2) AS doublecarrier_count,
		  MIN(alltable.t_stamp) AS Startstamp, 
		  Max(alltable.t_stamp) AS Endtstamp
		  
FROM alltable
		Where (alltable.t_stamp BETWEEN :starttime AND :endtime)
		Group BY 'Induct 1' ) basa