Попробуйте следующий фрагмент:
((Install_Count * 100) / Total Machines) AS Total_Percentage
Реализация кода:
select UI.ArticleID ,ui.DateLastModified,
SUM (CaSe WHEN (AAA.StateID = '2') Then 1 else 0
END) As Install_Count,
sum ( CASE
WHEN ((AAA.StateID = '2') and ( OPSYS.Caption0 like 'Microsoft Windows%10%')) THEN 1 else 0
END ) As 'W10',
sum ( CASE
WHEN ((AAA.StateID = '2') and (OPSYS.Caption0 = 'Microsoft Windows 7 Enterprise' or OPSYS.Caption0 = 'Microsoft Windows 7 Entreprise')) THEN 1 else 0
END ) As 'W7',
sum ( CASE
WHEN ((AAA.StateID != '2') and ((OPSYS.Caption0 not like 'Microsoft Windows%10%') and (OPSYS.Caption0 != 'Microsoft Windows 7 Enterprise') and (OPSYS.Caption0 != 'Microsoft Windows 7 Entreprise'))) THEN 1 else 0
END ) As 'Other',
count(AAA.ResourceID) As 'Total Machines',
((SUM (CaSe WHEN (AAA.StateID = '2') Then 1 else 0
END) *100)/count(AAA.ResourceID)) AS Total_percentage
FROM v_UpdateInfo UI
INNER JOIN v_CIAssignmentToCI CIA ON UI.CI_ID = CIA.CI_ID
INNER JOIN v_CIAssignment ON CIA.AssignmentID = v_CIAssignment.AssignmentID
Inner Join v_AssignmentStatePerTopic AAA on AAA.AssignmentID = CIA.AssignmentID
inner join v_GS_OPERATING_SYSTEM OPSYS on OPSYS.ResourceID=AAA.ResourceID
where CIA.AssignmentID = '1234567' and aaa.TopicType = '302'
Group By ui.Title, UI.ArticleID ,ui.DateLastModified
Отредактировано:
select UI.ArticleID ,ui.DateLastModified,
SUM (CaSe WHEN (AAA.StateID = '2') Then 1 else 0
END) As Install_Count,
sum ( CASE
WHEN ((AAA.StateID = '2') and ( OPSYS.Caption0 like 'Microsoft Windows%10%')) THEN 1 else 0
END ) As 'W10',
sum ( CASE
WHEN ((AAA.StateID = '2') and (OPSYS.Caption0 = 'Microsoft Windows 7 Enterprise' or OPSYS.Caption0 = 'Microsoft Windows 7 Entreprise')) THEN 1 else 0
END ) As 'W7',
sum ( CASE
WHEN ((AAA.StateID != '2') and ((OPSYS.Caption0 not like 'Microsoft Windows%10%') and (OPSYS.Caption0 != 'Microsoft Windows 7 Enterprise') and (OPSYS.Caption0 != 'Microsoft Windows 7 Entreprise'))) THEN 1 else 0
END ) As 'Other',
count(AAA.ResourceID) As 'Total Machines',
cast(((SUM (CaSe WHEN (AAA.StateID = '2') Then 1 else 0
END) *100)/count(AAA.ResourceID))as decimal(10,2)) AS Total_percentage
FROM v_UpdateInfo UI
INNER JOIN v_CIAssignmentToCI CIA ON UI.CI_ID = CIA.CI_ID
INNER JOIN v_CIAssignment ON CIA.AssignmentID = v_CIAssignment.AssignmentID
Inner Join v_AssignmentStatePerTopic AAA on AAA.AssignmentID = CIA.AssignmentID
inner join v_GS_OPERATING_SYSTEM OPSYS on OPSYS.ResourceID=AAA.ResourceID
where CIA.AssignmentID = '1234567' and aaa.TopicType = '302'
Group By ui.Title, UI.ArticleID ,ui.DateLastModified