• A bit simpler:

    SELECT

    t5.pgroup,

    CONVERT(NUMERIC(5,2),SUM(CASE WHEN t6.state = 'INSTALLED' THEN 100. END) / COUNT(*)) AS INSTALLED,

    CONVERT(NUMERIC(5,2),SUM(CASE WHEN t6.state = 'MISSING' THEN 100. END) / COUNT(*)) AS MISSING

    FROM

    table5 t5

    JOIN table6 t6 ON t5.patch = t6.patch

    GROUP BY t5.pgroup

    ORDER BY t5.pgroup

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2