I am creating a temporary table which is the union of three selects each producing an ID and a score. If I use UNION on its own I lose any duplicated rows. If I use UNION ALL I get some rows with the same ID but different scores. What I want instead is to end up with unique IDs with the score column being the sum of the scores for any duplicate rows. Is this possible? Does anyone have any suggestions?