SELECT SalesAgentId, SalesAgentName, SUM(SalesAmount) AS SalesAmount
INTO #AggSales
FROM Sales
GROUP BY SalesAgentId, SalesAgentName;
TRUNCATE TABLE Sales;
INSERT INTO Sales
SELECT * FROM #AggSales;
DROP TABLE #AggSales;
SELECT SalesAgentId, SalesAgentName, SUM(SalesAmount) AS SalesAmount
INTO #AggSales
FROM Sales
GROUP BY SalesAgentId, SalesAgentName;
TRUNCATE TABLE Sales;
INSERT INTO Sales
SELECT * FROM #AggSales;
DROP TABLE #AggSales;