SELECT
    roundtime,
    
    singlecarrier_count * 3600 / TIMESTAMPDIFF(SECOND, :starttime, :endtime) AS SingleCarrier_rate,
    doublecarrier_count * 3600 / TIMESTAMPDIFF(SECOND, :starttime, :endtime) AS DoubleCarrier_rate

FROM (
    SELECT
        COUNT(*) AS Total_count,
        SUM(alltable.Carrier_Count = 1) AS singlecarrier_count,
        SUM(alltable.Carrier_Count = 2) AS doublecarrier_count,
        FROM_UNIXTIME(CEIL(UNIX_TIMESTAMP(alltable.t_stamp) / 60) * 60) roundtime
    
    FROM alltable
    WHERE (alltable.t_stamp BETWEEN :starttime AND :endtime)
    GROUP BY FROM_UNIXTIME(CEIL(UNIX_TIMESTAMP(alltable.t_stamp) / 60) * 60)
    ORDER BY alltable.t_stamp ASC
) okey;

