我有一张桌子SoldCars
.
Id_Car Id_Color time 8 2 2015-02-11 8 4 2015-03-11 8 2 2015-04-11 5 2 2015-05-11 8 3 2015-08-11
我想查询以获取以下行集:
Id_car CountColors 8 3 5 1
哪里Id_car
是独特的,Id_Car
并且CountColors
是不同数量的颜色的数量.
我尝试了很多SQL查询,但结果远非如此.
例如:
Select dictinct Id_Car, count(Id_Color) as CountColors from SoldCars group by Id_car
Tobias Baume.. 5
SELECT Id_car, count(DISTINCT Id_Color) AS CountColors FROM SoldCars GROUP BY Id_car
这应该做的工作:)
SELECT Id_car, count(DISTINCT Id_Color) AS CountColors FROM SoldCars GROUP BY Id_car
这应该做的工作:)