73 lines
3.1 KiB
Plaintext
73 lines
3.1 KiB
Plaintext
Select
|
|
SorterName,Lane,Startstamp,Endtstamp,
|
|
Total_count, DivertFail_count,Diverted_count,
|
|
DestFull_count,DestJam_count,DestDis_count,
|
|
DestFault_count,Lost_count,Unsafe_count,Dim_count,GapErr_count,Unknown_count,
|
|
|
|
Total_count/Total_count as total_perc,
|
|
DivertFail_count/Total_count as DivertFail_perc,
|
|
Diverted_count/Total_count as Diverted_perc,
|
|
DestFull_count/Total_count as destfull_perc,
|
|
DestJam_count/Total_count as destjam_perc,
|
|
DestDis_count/Total_count as destdisabled_perc,
|
|
DestFault_count/Total_count as destfault_perc,
|
|
Lost_count/Total_count as lost_perc,
|
|
Unsafe_count/Total_count as unsafe_perc,
|
|
Dim_count/Total_count as dim_perc,
|
|
GapErr_count/Total_count as gaperr_perc,
|
|
Unknown_count/Total_count as unknown_perc,
|
|
|
|
Total_count*3600/TIMESTAMPDIFF(second, :starttime, :endtime) as total_rate,
|
|
DivertFail_count*3600/TIMESTAMPDIFF(second, :starttime, :endtime) as DivertFail_rate,
|
|
Diverted_count*3600/TIMESTAMPDIFF(second, :starttime, :endtime) as Diverted_rate,
|
|
DestFull_count*3600/TIMESTAMPDIFF(second, :starttime, :endtime) as destfull_rate,
|
|
DestJam_count*3600/TIMESTAMPDIFF(second, :starttime, :endtime) as destjam_rate,
|
|
DestDis_count*3600/TIMESTAMPDIFF(second, :starttime, :endtime) as destdisabled_rate,
|
|
DestFault_count*3600/TIMESTAMPDIFF(second, :starttime, :endtime) as destfault_rate,
|
|
Lost_count*3600/TIMESTAMPDIFF(second, :starttime, :endtime) as lost_rate,
|
|
Unsafe_count*3600/TIMESTAMPDIFF(second, :starttime, :endtime) as unsafe_rate,
|
|
Dim_count*3600/TIMESTAMPDIFF(second, :starttime, :endtime) as dim_rate,
|
|
GapErr_count*3600/TIMESTAMPDIFF(second, :starttime, :endtime) as gaperr_rate,
|
|
Unknown_count*3600/TIMESTAMPDIFF(second, :starttime, :endtime) as unknown_rate
|
|
FROM
|
|
(Select
|
|
'S03' AS SorterName,
|
|
alltable.DEST_REQ as Lane,
|
|
COUNT(*) AS Total_count,
|
|
SUM(alltable.ACTUAL_DEST <> 'S03999') AS Diverted_count,
|
|
SUM(alltable.DivertStatus = 14) AS DivertFail_count,
|
|
SUM(alltable.DivertStatus = 5) AS DestFull_count,
|
|
SUM(alltable.DivertStatus = 6) AS DestJam_count,
|
|
SUM(alltable.DivertStatus = 12) AS DestDis_count,
|
|
MIN(alltable.t_stamp) AS Startstamp,
|
|
Max(alltable.t_stamp) AS Endtstamp,
|
|
SUM(alltable.DivertStatus = 6) as DestFault_count,
|
|
SUM(alltable.DivertStatus = 17) as Lost_count,
|
|
SUM(alltable.DivertStatus = 21) as Unsafe_count,
|
|
SUM(alltable.DivertStatus = 18) as Dim_count,
|
|
SUM(alltable.DivertStatus = 4) as GapErr_count,
|
|
SUM(alltable.DivertStatus = 1) as Unknown_count
|
|
FROM alltable
|
|
Where (alltable.DEST_REQ <> 'S03999' AND alltable.t_stamp BETWEEN :starttime AND :endtime)
|
|
Group BY alltable.DEST_REQ
|
|
Union
|
|
Select
|
|
'S03' AS SorterName,
|
|
alltable.ACTUAL_DEST as Lane,
|
|
COUNT(*) AS Total_count,
|
|
COUNT(*) AS Diverted_count,
|
|
0 AS DivertFail_count,
|
|
0 AS DestFull_count,
|
|
0 AS DestJam_count,
|
|
0 AS DestDis_count,
|
|
MIN(alltable.t_stamp) AS Startstamp,
|
|
Max(alltable.t_stamp) AS Endtstamp,
|
|
0 as DestFault_count,
|
|
0 as Lost_count,
|
|
0 as Unsafe_count,
|
|
0 as Dim_count,
|
|
0 as GapErr_count,
|
|
0 as Unknown_count
|
|
FROM alltable
|
|
Where (alltable.ACTUAL_DEST = 'S03999' AND alltable.t_stamp BETWEEN :starttime AND :endtime)) basa
|
|
|