Count Windows Update Agent versions

The following SQL query counts the Windows Update Agent (WUA) versions by workstations and servers. The WUA is updated via Windows Updates and is the component on Windows systems that applies and reports compliances for patches.

/*  Count Windows Update Agents by Platform and WUA versions */
SELECT 'Workstation' as 'Platform', WUAV.Version0 as 'Version', count(*) as 'Count'
FROM v_GS_WINDOWSUPDATEAGENTVERSION WUAV
JOIN v_R_System Sys ON WUAV.ResourceID = Sys.ResourceID
join v_GS_SYSTEM S on S.ResourceID=WUAV.ResourceID
WHERE WUAV.Version0 <> 'ISNULL' and S.SystemRole0='Workstation'
Group by WUAV.Version0
UNION
SELECT 'Server' as 'Platform', WUAV.Version0 as 'Version', count(*) as 'Count'
FROM v_GS_WINDOWSUPDATEAGENTVERSION WUAV
JOIN v_R_System Sys ON WUAV.ResourceID = Sys.ResourceID
join v_GS_SYSTEM S on S.ResourceID=WUAV.ResourceID
WHERE WUAV.Version0 <> 'ISNULL' and S.SystemRole0='Server'
Group by WUAV.Version0
ORDER BY Platform, WUAV.Version0 desc