loan returns

mail@pastecode.io avatar
unknown
mysql
15 days ago
473 B
3
Indexable
Never
SELECT 
    l.headerid, l.status, l.notes, i.*
FROM
    (SELECT 
        CONCAT('s', serialnumber) serial,
            product,
            size,
            bin,
            location,
            previouslocation,
            lastscandate
    FROM
        inventoryitem
    WHERE
        location = 'returns'
            AND previouslocation = 'loaned'
            AND qtyonhand = 1
    ORDER BY lastscandate ASC) i
        JOIN
    loanitem l ON l.serialnumber = i.serial
Leave a Comment