Fix induct detailes sqls

This commit is contained in:
Gigi Mamaladze 2025-05-13 13:57:46 +04:00
parent 193547368f
commit 0a111767c1
3 changed files with 25 additions and 39 deletions

View File

@ -32168,7 +32168,7 @@
},
"props": {
"dismissOnSelect": false,
"formattedValue": "May 7, 2025 12:11 PM",
"formattedValue": "May 13, 2025 11:34 AM",
"formattedValues": {
"date": "Mar 26, 2021",
"datetime": "Mar 26, 2021 12:00 AM",
@ -32178,9 +32178,9 @@
"$": [
"ts",
192,
1746609088108
1747125250352
],
"$ts": 1746605488000
"$ts": 1747121650000
}
},
"type": "ia.input.date-time-input"
@ -32328,7 +32328,7 @@
},
"props": {
"dismissOnSelect": false,
"formattedValue": "May 7, 2025 1:11 PM",
"formattedValue": "May 13, 2025 12:34 PM",
"formattedValues": {
"date": "Mar 29, 2021",
"datetime": "Mar 29, 2021 1:37 PM",
@ -32338,9 +32338,9 @@
"$": [
"ts",
192,
1746609088104
1747125250351
],
"$ts": 1746609088000
"$ts": 1747125250000
}
},
"type": "ia.input.date-time-input"

View File

@ -1,18 +1,12 @@
Select
SorterName,InductName,Total_count,singlecarrier_count,doublecarrier_count,Startstamp,Endtstamp,
SorterName,InductName,Total_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
Total_count*3600/TIMESTAMPDIFF(second, Startstamp, Endtstamp) as Total_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

View File

@ -1,25 +1,17 @@
Select
roundtime,
Total_count,singlecarrier_count,doublecarrier_count,
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, :starttime, :endtime) as Total_rate,
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.ParcelHistory_TupelLength = 1) AS singlecarrier_count,
SUM(alltable.ParcelHistory_TupelLength = 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) and ('Induct 1' = :Induct)
Group BY FROM_UNIXTIME(CEIL(UNIX_TIMESTAMP(alltable.t_stamp) / 60) * 60)
/***Order By alltable.t_stamp ASC ***/
) okey
SELECT
okey.roundtime,
okey.Total_count,
okey.Total_count / okey.Total_count AS Total_perc,
okey.Total_count * 3600
/ TIMESTAMPDIFF(SECOND, :starttime, :endtime) AS Total_rate
FROM (
SELECT
FROM_UNIXTIME(
CEIL(UNIX_TIMESTAMP(alltable.t_stamp) / 60) * 60
) AS roundtime,
COUNT(*) AS Total_count
FROM alltable
WHERE (alltable.t_stamp BETWEEN :starttime AND :endtime) and ('Induct 1' = :Induct)
GROUP BY roundtime
) AS okey
ORDER BY okey.roundtime;