If I have a table of fruits:
FruitId ColorId NumofPurchased
.
I want to return a row for each of the colorId's where NumOfPurchased is max for that colorId. I am coming up with approaches like looping through the colorId's or manually write 10 queries for 10 colors ... I don't know, is there a better/more optimized way to do this?
I am using SQL Server 2008 express.