COUNT(*) OVER()
memberi Anda jumlah total.
Sunting Tetapi sebenarnya Anda membutuhkan SUM(COUNT(MyTbl.ItemID)) OVER()
saat Anda menjumlahkan nilai dalam kolom tersebut.
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