COUNT(*) OVER()
giver dig det samlede antal.
Rediger Men faktisk har du brug for SUM(COUNT(MyTbl.ItemID)) OVER()
som du summerer værdierne i den kolonne.
SELECT Items.ItemID,
[count] = COUNT(MyTbl.ItemID),
[Percent] = 100.0 * COUNT(MyTbl.ItemID) / SUM(COUNT(MyTbl.ItemID)) OVER()
FROM (VALUES (1,'N1'),
(2,'N2'),
(3,'N4'),
(4,'N5')) Items(ItemID, ItemName)
LEFT JOIN (VALUES(1),
(1),
(3),
(4),
(4),
(4)) MyTbl(ItemID)
ON ( MyTbl.ItemID = Items.ItemID )
GROUP BY Items.ItemID
ORDER BY Items.ItemID