salix/print/templates/reports/extra-community/sql/travels.sql

23 lines
907 B
MySQL
Raw Normal View History

2021-06-16 11:04:54 +00:00
SELECT
t.id,
t.ref,
t.shipped,
t.landed,
t.kg,
2022-03-28 11:24:26 +00:00
am.id AS agencyModeFk,
2021-06-16 11:04:54 +00:00
SUM(b.stickers) AS stickers,
2022-08-24 12:13:26 +00:00
CAST(SUM(b.weight * b.stickers) as DECIMAL(10,0)) as loadedKg,
CAST(SUM(vc.aerealVolumetricDensity * b.stickers * IF(pkg.volume, pkg.volume, pkg.width * pkg.depth * pkg.height) / 1000000) as DECIMAL(10,0)) as volumeKg
2021-06-16 11:04:54 +00:00
FROM travel t
2022-09-27 09:26:36 +00:00
JOIN volumeConfig vc
2021-06-16 11:04:54 +00:00
LEFT JOIN supplier s ON s.id = t.cargoSupplierFk
LEFT JOIN entry e ON e.travelFk = t.id
LEFT JOIN buy b ON b.entryFk = e.id
LEFT JOIN packaging pkg ON pkg.id = b.packageFk
LEFT JOIN item i ON i.id = b.itemFk
LEFT JOIN itemType it ON it.id = i.typeFk
JOIN warehouse w ON w.id = t.warehouseInFk
JOIN warehouse wo ON wo.id = t.warehouseOutFk
JOIN country c ON c.id = wo.countryFk
LEFT JOIN continent cnt ON cnt.id = c.continentFk
2022-08-10 10:13:31 +00:00
JOIN agencyMode am ON am.id = t.agencyModeFk