Untitled

mail@pastecode.io avatar
unknown
mysql
2 years ago
1.4 kB
1
Indexable
Never
SELECT 
    COUNT(i.serialnumber) UnitTotal,
    COUNT(DISTINCT i.bin) CountofBins,
    CASE
        WHEN product LIKE '%-_Z%' THEN 'Shoes'
        WHEN
            (i.location LIKE '7-D62%'
                OR i.location LIKE '7-D63%'
                OR i.location LIKE '7-E99%'
                OR i.location LIKE '7-E100%'
                OR i.location LIKE '7-E101%'
                OR i.location LIKE '7-E102%'
                OR i.location LIKE '7-E103%'
                OR i.location LIKE '7-E104%'
                OR i.location LIKE '7-E105%'
                OR i.location LIKE '7-UE105%')
        THEN
            'GOH'
        WHEN
            bin = ''
                AND (product LIKE '____-_Y%'
                OR product LIKE '____-_A%')
        THEN
            'Bags'
        WHEN
            bin = ''
                AND (product NOT LIKE '____-_Y%'
                OR product NOT LIKE '____-_A%')
        THEN
            'Misc'
        WHEN bin != '' THEN 'Standard Bins'
        ELSE 'null'
    END AS InvType
FROM
    (SELECT 
        serialnumber, product, size, bin, location
    FROM
        inventoryitem
    WHERE
        (location LIKE '7-E%'
            OR location LIKE '7-D%'
            OR location LIKE '7-UD%')
            AND location not like '7-E30__%'
            AND qtyonhand = 1) i
        JOIN
    product p ON p.code = i.product AND p.siteflag = 'F'
GROUP BY InvType