salix/print/templates/reports/invoice/sql/tickets.sql

12 lines
316 B
SQL

SELECT
t.id,
t.shipped,
t.nickname,
tto.description
FROM invoiceOut io
JOIN ticket t ON t.refFk = io.ref
LEFT JOIN ticketObservation tto ON tto.ticketFk = t.id
AND tto.observationTypeFk = (SELECT id FROM observationType WHERE code = 'invocieOut')
WHERE t.refFk = ?
ORDER BY t.shipped