Menggunakan OVER(PARTITION BY ), Anda tidak perlu bergabung di SQL Server
SELECT *, 100*Grade/ SUM(Grade) OVER(PARTITION BY ID) AS Percentage
FROM (
VALUES(1, 10),(1,20), (2, 15), (2,24), (2,16), (3,29)
) your_table (ID, GRADE)
Menggunakan OVER(PARTITION BY ), Anda tidak perlu bergabung di SQL Server
SELECT *, 100*Grade/ SUM(Grade) OVER(PARTITION BY ID) AS Percentage
FROM (
VALUES(1, 10),(1,20), (2, 15), (2,24), (2,16), (3,29)
) your_table (ID, GRADE)