
Is there a way of populating the Cust1, Cust2, Cust3 columns in Table2 that doesn't involve running the same query with several different "WHERE" clauses?
For example, right now I would resort to doing this:
INSERT INTO Table2(Cust1_Totals)
SELECT Fruit, SUM(quantity)
FROM Table1
WHERE Customer_ID LIKE 1
GROUP BY Fruit
INSERT INTO Table2(Cust2_Totals)
SELECT Fruit, SUM(quantity)
FROM Table1
WHERE Customer_ID LIKE 2
GROUP BY Fruit
INSERT INTO Table2(Cust3_Totals)
SELECT Fruit, SUM(quantity)
FROM Table1
WHERE Customer_ID LIKE 3
GROUP BY Fruit
Ideally, I would like to have another table with a Customer_ID column of all the unique customers and then I would reference each one in a loop in the above query. SQL Server 2008.