• DataAnalyst011 (12/12/2012)


    ...In my production project, the values don't exist and I use the variables to print them into a row for a business process need...

    OK, so if I'm understanding this then you still want the items from ProgTbl even if there are no matching records in tblCount? Then the join would be a LEFT OUTER JOIN like this:

    INSERT INTO ProgTbl

    (Prog)

    VALUES

    ('XX-99')

    INSERT INTO FinalTbl(Total, Prog)

    SELECT COUNT(c.prog), p.Prog

    FROM ProgTbl p

    LEFT OUTER JOIN tblCount c ON p.Prog = c.Prog

    GROUP BY p.Prog