fix: solo un trabajador por fallo #2210
|
@ -37,7 +37,7 @@ BEGIN
|
||||||
WITH rankedWorkers AS (
|
WITH rankedWorkers AS (
|
||||||
SELECT sm.id,
|
SELECT sm.id,
|
||||||
st.workerFk,
|
st.workerFk,
|
||||||
ROW_NUMBER() OVER(PARTITION BY sm.id ORDER BY s2.`order`) AS rnk
|
ROW_NUMBER() OVER(PARTITION BY sm.id ORDER BY s2.`order`) rnk
|
||||||
FROM vn.saleMistake sm
|
FROM vn.saleMistake sm
|
||||||
JOIN vn.saleTracking st ON sm.saleFk = st.saleFk
|
JOIN vn.saleTracking st ON sm.saleFk = st.saleFk
|
||||||
jgallego marked this conversation as resolved
|
|||||||
JOIN vn.`state` s2 ON s2.id = st.stateFk
|
JOIN vn.`state` s2 ON s2.id = st.stateFk
|
||||||
|
@ -46,7 +46,7 @@ BEGIN
|
||||||
WHERE t.shipped BETWEEN vDatedFrom AND vDatedTo
|
WHERE t.shipped BETWEEN vDatedFrom AND vDatedTo
|
||||||
AND s2.code IN ('OK', 'PREVIOUS_PREPARATION', 'PREPARED', 'CHECKED')
|
AND s2.code IN ('OK', 'PREVIOUS_PREPARATION', 'PREPARED', 'CHECKED')
|
||||||
)
|
)
|
||||||
SELECT workerFk, COUNT(*) AS errors
|
SELECT workerFk, COUNT(*) errors
|
||||||
FROM rankedWorkers
|
FROM rankedWorkers
|
||||||
WHERE rnk = 1
|
WHERE rnk = 1
|
||||||
GROUP BY workerFk;
|
GROUP BY workerFk;
|
||||||
|
|
Loading…
Reference in New Issue
esquema vn se puede eliminar
dins dels WITH si no es posa l'esquema myt falla.