I have searched through what appear to be relevant questions but am still unable to solve my issue.
SELECT c.name AS 'Computer', COUNT(h.hotfixid) AS '# Missing',
CASE
WHEN COUNT(h.hotfixid) ='0' THEN 'Fully Patched'
WHEN COUNT(h.hotfixid) BETWEEN 1 AND 4 THEN '1 - 4 Missing'
WHEN COUNT(h.hotfixid) BETWEEN 5 AND 12 THEN '5 - 12 Missing'
WHEN COUNT(h.hotfixid) >12 THEN 'Attention > 12 Missing'
END AS 'Status',
c.os AS 'Operating System'
FROM hotfix h
LEFT JOIN computers c ON h.computerid=c.computerid
LEFT JOIN clients cl ON c.clientid=cl.clientid
WHERE h.Installed='0' AND h.Approved='1' AND c.clientid = '229'
GROUP BY c.name
The problem is that the above will not return anything that has a 0 or no records. The GROUP BY breaks it.
This query returns my expected result, but when I add GROUP BY to it no results are returned at all.
SELECT
CASE
WHEN COUNT(hotfixid) ='0' THEN 'Fully Patched'
WHEN COUNT(hotfixid) BETWEEN 1 AND 4 THEN '1 - 4 Missing'
WHEN COUNT(hotfixid) BETWEEN 5 AND 12 THEN '5 - 12 Missing'
WHEN COUNT(hotfixid) >12 THEN 'Attention > 12 Missing'
END AS 'Status'
FROM hotfix
WHERE computerid = '8176' AND hotfix.`approved` = '1' AND hotfix.`installed` = '0'
This query returns a 0, so I know I'm getting 0 and not a 'NULL'
SELECT computerid,
COUNT(hotfixid)
FROM hotfix
WHERE computerid = '8176' AND hotfix.`approved` = '1' AND hotfix.`installed` = '0'
Edit.
The hotfix table Info:
My expected output is to list by machines, their patching status, but the Fully Patched Status wont display:
Thanks for any assistance.
Regards Peter.