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

20 lines
637 B
MySQL
Raw Permalink Normal View History

SELECT ep.id palletFk,
t.routeFk,
rs2.description truck,
r.description `zone`,
COUNT(es.id) labels,
t.warehouseFk warehouseFk,
dayname(r.created) `dayName`,
rs.id <=> rm.roadmapStopFk isMatch
FROM vn.roadmapStop rs
JOIN vn.expeditionPallet ep ON ep.truckFk = rs.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.roadmapStop rs2 ON rs2.id = rm.roadmapStopFk
WHERE ep.id = ?
GROUP BY ep.id, t.routeFk
2023-04-05 10:01:42 +00:00
ORDER BY t.routeFk