Reputation: 3986
I have created a query to get the Win 7 and Win 10 count in SCCM. Everything is working fine but Output is not coming the way I wanted.
Current Output
DeploymentName CollectionName Available Deadline ReportTime W10 W7
WKS 2019-10 WKS 2019-10 20:23.0 00:00.0 18:00.0 14116 0
WKS 2019-10 WKS 2019-10 20:23.0 00:00.0 18:00.0 27 0
WKS 2019-10 WKS 2019-10 20:23.0 00:00.0 18:00.0 0 2886
WKS 2019-10 WKS 2019-10 20:23.0 00:00.0 18:00.0 0 1
Expected Output
DeploymentName CollectionName Available Deadline ReportTime W10 W7
WKS 2019-10 WKS 2019-10 20:23.0 00:00.0 18:00.0 14143 2887
Query which i have created.
SELECT
CIA.AssignmentName as DeploymentName, CIA.CollectionName as CollectionName, CIA.CreationTime as Available,
CIA.EnforcementDeadline as Deadline, CIA.StartTime as ReportTime, --OPSYS.Caption0 as [Operating System],
--COUNT(*) AS 'Count' ,
sum ( CASE
WHEN OPSYS.Caption0 = 'Microsoft Windows 10 Enterprise' or OPSYS.Caption0 = 'Microsoft Windows 10 Pro' THEN 1 else 0
END ) As 'W10',
sum ( CASE
WHEN OPSYS.Caption0 = 'Microsoft Windows 7 Enterprise' or OPSYS.Caption0 = 'Microsoft Windows 7 Entreprise' THEN 1 else 0
END ) As 'W7'
FROM v_GS_OPERATING_SYSTEM OPSYS
inner join V_R_System sys on OPSYS.ResourceID=sys.ResourceID
Inner join v_FullCollectionMembership FCM on FCM.ResourceID = SYS.ResourceID
--Inner join v_Collection COL on fcm.CollectionID = col.CollectionID
inner join v_CIAssignment CIA on CIA.CollectionID = FCM.CollectionID
WHERE
CIA.AssignmentName = 'WKS 2019-10 '
group by CIA.AssignmentName, CIA.CollectionName, CIA.CreationTime,
CIA.EnforcementDeadline, CIA.StartTime, OPSYS.Caption0
What am I doing wrong here?
Upvotes: 2
Views: 60
Reputation: 1269773
Remove the caption from the GROUP BY
:
group by CIA.AssignmentName, CIA.CollectionName, CIA.CreationTime,
CIA.EnforcementDeadline, CIA.StartTime
Upvotes: 2