Mysql
 sql >> Base de Dados >  >> RDS >> Mysql

MYSQL:JOIN faz SUM dobrar

SELECT t.pid, p.name AS 'Part Name', t.InStock AS 'In Stock'
    FROM (SELECT pid, SUM(qty_left) AS InStock
              FROM not_piece
              GROUP BY pid) t
        INNER JOIN part p
            ON t.pid = p.pid