我想从表中选择并返回列中特定值的出现次数。
我还希望该值的出现次数出现在结果集中。
例如
有了这个汽车桌
type color
===== ===
bmw blue
lexus green
Ford blue
KIA yellow
我想构建一个将返回以下结果的查询。
type color colorcount
===== === =======
bmw blue 2
lexus green 1
Ford blue 2
KIA yellow 1
我试过:
select type,color, count(color) from Car
但这显然没有用。有谁知道如何做到这一点?