Untitled

mail@pastecode.io avatar
unknown
mysql
a year ago
553 B
5
Indexable
SELECT p.*, GROUP_CONCAT(DISTINCT o.location, ';', o.bin) AS locations FROM (SELECT DATE(orderdate) AS orderdate, DATE(printbatch) AS printbatch, invoice, productcode, option1, serialnumber, itemlocation FROM shipment
WHERE status = 'cant find' AND DATE(orderdate) <= DATE_SUB(CURRENT_DATE, INTERVAL 3 DAY) AND DATE(printbatch) <= DATE_SUB(CURRENT_DATE, INTERVAL 3 DAY) AND productcode NOT LIKE 'ralt-%')p
LEFT JOIN inventoryitem o ON productcode = product AND option1 = size AND qtyonhand = 1 GROUP BY p.invoice , product , size ORDER BY locations ASC;