Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
723 B
3
Indexable
Never
SELECT 
                    stk.prdno AS Codigo,
                    stk.grade AS Grade,
                    (ROUND(((stk.qtty_varejo+stk.qtty_atacado) / 1000),0) - IFNULL(ROUND(((devf.qtty_varejo+devf.qtty_atacado) / 1000),0),0)) AS qtd
            FROM sqldados.stk
            INNER JOIN sqldados.prd ON stk.prdno = prd.no
            LEFT JOIN sqldados.devf ON stk.storeno = devf.storeno AND stk.prdno = devf.prdno AND stk.grade = devf.grade
            WHERE stk.storeno = :store
            AND stk.prdno = :productCode
            AND stk.grade LIKE CONCAT(:grade , '%')
            AND stk.qtty_varejo+stk.qtty_atacado > 0
            GROUP BY stk.storeno,stk.prdno,stk.grade
            HAVING qtd > 0;
Leave a Comment