Untitled

mail@pastecode.io avatar
unknown
mysql
a year ago
728 B
4
Indexable
Never
SELECT 
    CONCAT('s', serialnumber) AS serial,
    product,
    size,
    location,
    bin,
    previouslocation,
    lastscandate,
    removedate,
    TIMESTAMPDIFF(DAY,
        removedate,
        lastscandate) AS found_interval,
    SUBSTRING_INDEX(SUBSTRING_INDEX(notes, ':', 1), '[', - 1) AS reason
FROM
    inventoryitem j2
WHERE
    location LIKE '7-%'
        AND location NOT LIKE '7-T%'
        AND location NOT LIKE '7-800%'
        AND location NOT LIKE '7-R%'
        AND location NOT LIKE '7-S%'
        AND location NOT LIKE '7-Q%'
        AND location NOT LIKE '7-444_-%'
        AND lastscandate >= (CURRENT_DATE - INTERVAL 2 DAY)
        AND qtyonhand = 0
HAVING reason IN ('OOS on' , 'Manual decrement on')