• Actually Sean's code will give you the counts you're looking for, and in a more efficient manner than trying to get each one separately using the variable. If the ProgTbl restricts the Prog values or has Prog values that don't match any record in tblCount, then maybe do it as a join?

    INSERT INTO FinalTbl(Total, Prog)

    SELECT COUNT(*), p.Prog

    FROM ProgTbl p

    INNER JOIN tblCount c ON p.Prog = c.Prog

    GROUP BY p.Prog