salix/print/templates/reports/delivery-note/sql/ticket.sql

12 lines
320 B
SQL

SELECT
t.id,
t.shipped,
c.code companyCode,
t.packages,
tto.description
FROM ticket t
JOIN company c ON c.id = t.companyFk
LEFT JOIN ticketObservation tto
ON tto.ticketFk = t.id
AND tto.observationTypeFk = (SELECT id FROM observationType WHERE code = 'deliveryNote')
WHERE t.id = ?