I have the following data:
| Car Type | Car Color | Cars Sold |
|---|---|---|
| Convertible | Blue | 31 |
| Sedan | Red | 20 |
| Truck | Red | 10 |
| Coupe | Black | 9 |
| Mini Van | Red | 8 |
| Convertible | White | 4 |
| Sedan | Red | 9 |
| Truck | Black | 12 |
| Coupe | Silver | 11 |
| Mini Van | Blue | 4 |
I want to be able to aggregate the car type, car color while also finding the max cars sold for the car type --- so the end result would look like this:
| Car Type | Car Color | Cars Sold |
|---|---|---|
| Convertible | Blue | 31 |
| Sedan | Red | 20 |
| Mini Van | Red | 8 |
| Truck | Black | 12 |
| Coupe | Silver | 11 |
I have the following:
SELECT CarType, CarColor, MAX(CarsSold)
FROM CarTable
GROUP BY CarType
But I get an aggregate error which I'm not sure how to fix?