COUNT(*) OVER()
geeft je het totale aantal.
Bewerken Maar eigenlijk heb je SUM(COUNT(MyTbl.ItemID)) OVER()
nodig terwijl u de waarden in die kolom optelt.
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