BNA8/.resources/ee5d0c01379cd4762efc1e00f74d7cce619003f8117ae36a4958a57e0f022180

34 lines
1.9 KiB
Plaintext

Select
roundtime,
Induct_count,Sorted_count,OperRecirc_count,MachineRecirc_count,AWCSRecirc_count,
Induct_count/Induct_count as Induct_perc,
Sorted_count/Induct_count as Sorted_perc,
OperRecirc_count/Induct_count as OperRecirc_perc,
MachineRecirc_count/Induct_count as MachineRecirc_perc,
AWCSRecirc_count/Induct_count as AWCSRecirc_perc,
Induct_count*3600/TIMESTAMPDIFF(second, :starttime, :endtime) as Induct_rate,
Sorted_count*3600/TIMESTAMPDIFF(second, :starttime, :endtime) as Sorted_rate,
OperRecirc_count*3600/TIMESTAMPDIFF(second, :starttime, :endtime) as OperRecirc_rate,
MachineRecirc_count*3600/TIMESTAMPDIFF(second, :starttime, :endtime) as MachineRecirc_rate,
AWCSRecirc_count*3600/TIMESTAMPDIFF(second, :starttime, :endtime) as AWCSRecirc_rate
FROM
(SELECT
COUNT(*) AS Induct_count,
SUM(alltable.ACTUAL_DEST <> 'S03999') AS Sorted_count,
SUM(alltable.ACTUAL_DEST = 'S03999' AND (alltable.DivertStatus = 2 OR alltable.DivertStatus = 5 OR alltable.DivertStatus = 18 OR alltable.DivertStatus = 19 or alltable.DivertStatus = 20)) AS OperRecirc_count,
SUM(alltable.ACTUAL_DEST = 'S03999' AND (alltable.DivertStatus = 1 OR alltable.DivertStatus = 3 OR alltable.DivertStatus = 4 OR alltable.DivertStatus = 6 OR alltable.DivertStatus = 13 OR alltable.DivertStatus = 14 OR alltable.DivertStatus = 17 OR alltable.DivertStatus = 21)) AS MachineRecirc_count,
SUM(alltable.ACTUAL_DEST = 'S03999' AND (alltable.DivertStatus = 7 OR alltable.DivertStatus = 8 OR alltable.DivertStatus = 9 OR alltable.DivertStatus = 10 OR alltable.DivertStatus = 12 OR alltable.DivertStatus = 16)) AS AWCSRecirc_count,
FROM_UNIXTIME(CEIL(UNIX_TIMESTAMP(alltable.t_stamp) / 60) * 60) roundtime
FROM alltable
Where (alltable.t_stamp BETWEEN :starttime AND :endtime) AND ('S03' = :Sorter)
Group BY FROM_UNIXTIME(CEIL(UNIX_TIMESTAMP(alltable.t_stamp) / 60) * 60)
Order By alltable.t_stamp ASC
) okey