salix/print/templates/reports/expedition-pallet-label/sql/labelData.sql

20 lines
653 B
MySQL
Raw Normal View History

SELECT ep.id palletFk,
t.routeFk,
et2.description truck,
r.description `zone`,
COUNT(es.id) labels,
t.warehouseFk warehouseFk,
dayname(r.created) `dayName`,
et.id <=> rm.expeditionTruckFk isMatch
FROM vn.expeditionTruck et
JOIN vn.expeditionPallet ep ON ep.truckFk = et.id
JOIN vn.expeditionScan es ON es.palletFk = ep.id
JOIN vn.expedition e ON e.id = es.expeditionFk
JOIN vn.ticket t ON t.id = e.ticketFk
JOIN vn.route r ON r.id = t.routeFk
2023-04-05 10:01:42 +00:00
LEFT JOIN vn.routesMonitor rm ON rm.routeFk = r.id
LEFT JOIN vn.expeditionTruck et2 ON et2.id = rm.expeditionTruckFk
WHERE ep.id = ?
GROUP BY ep.id, t.routeFk
2023-04-05 10:01:42 +00:00
ORDER BY t.routeFk