2022-11-29 10:56:05 +00:00
|
|
|
SELECT tc.collectionFk,
|
|
|
|
SUBSTRING('ABCDEFGH', tc.wagon, 1) wagon,
|
|
|
|
tc.`level`,
|
|
|
|
t.id ticketFk,
|
|
|
|
COALESCE(et.description, zo.name, am.name) agencyDescription,
|
2022-10-04 08:55:13 +00:00
|
|
|
am.name,
|
|
|
|
t.clientFk,
|
2022-11-29 10:56:05 +00:00
|
|
|
CAST(SUM(sv.volume) AS DECIMAL(5, 2)) volume,
|
|
|
|
MAX(i.`size`) `size`,
|
|
|
|
ic.code,
|
2022-10-04 08:55:13 +00:00
|
|
|
w.code workerCode,
|
2022-11-29 10:56:05 +00:00
|
|
|
TIME_FORMAT(t.shipped, '%H:%i') shippedHour,
|
|
|
|
TIME_FORMAT(zo.`hour`, '%H:%i') zoneHour,
|
2022-11-08 13:40:38 +00:00
|
|
|
DATE_FORMAT(t.shipped, '%d/%m/%y') shipped,
|
2022-11-29 10:56:05 +00:00
|
|
|
t.nickName,
|
|
|
|
tt.labelCount,
|
|
|
|
COUNT(*) lineCount
|
2022-10-04 08:55:13 +00:00
|
|
|
FROM vn.ticket t
|
2022-11-29 10:56:05 +00:00
|
|
|
LEFT JOIN vn.ticketCollection tc ON tc.ticketFk = t.id
|
|
|
|
LEFT JOIN vn.collection c ON c.id = tc.collectionFk
|
2022-10-04 08:55:13 +00:00
|
|
|
LEFT JOIN vn.collectionColors cc ON cc.shelve = tc.`level`
|
|
|
|
AND cc.wagon = tc.wagon
|
|
|
|
AND cc.trainFk = c.trainFk
|
|
|
|
JOIN vn.sale s ON s.ticketFk = t.id
|
|
|
|
LEFT JOIN vn.saleVolume sv ON sv.saleFk = s.id
|
|
|
|
JOIN vn.item i ON i.id = s.itemFk
|
|
|
|
JOIN vn.itemType it ON it.id = i.typeFk
|
|
|
|
JOIN vn.itemCategory ic ON ic.id = it.categoryFk
|
2022-11-29 10:56:05 +00:00
|
|
|
LEFT JOIN vn.worker w ON w.id = c.workerFk
|
2022-10-04 08:55:13 +00:00
|
|
|
JOIN vn.agencyMode am ON am.id = t.agencyModeFk
|
|
|
|
LEFT JOIN vn.ticketTrolley tt ON tt.ticket = t.id
|
|
|
|
LEFT JOIN vn.`zone` zo ON t.zoneFk = zo.id
|
|
|
|
LEFT JOIN vn.routesMonitor rm ON rm.routeFk = t.routeFk
|
|
|
|
LEFT JOIN vn.expeditionTruck et ON et.id = rm.expeditionTruckFk
|
2022-11-29 10:56:05 +00:00
|
|
|
WHERE t.id IN (?)
|
2022-10-04 08:55:13 +00:00
|
|
|
GROUP BY t.id
|
|
|
|
ORDER BY cc.`code`;
|