Self-Inflicted SQL
Subject:   Summing up data from a table
Date:   2004-10-19 03:55:35
From:   Sona
I have 2 integer columns and want to sum up the commission with same trackId and insert it into another column of same table.But with Sum()function, I don't get as many number of sums as the number of rows in the table. My hard coded query looks like:

UPDATE Temp_GetPercentage
SET relPercentage = (SELECT sum(per.intImpressions)
FROM Temp_GetPercentage as per WHERE track_id = 20)

This should update all records with track_id = 20 and set relPercentage = (sum of intImpressions having track_id = 20)