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
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