我粘贴了表格的记录,以便您可以帮我查询。
........................................
car_id | mark | model | prize
........................................
1 | fiat | 500 | 15000
2 | fiat | panda | 8000
3 | opel | astra | 20000
4 | renault | clio | 14000
5 | opel | corsa | 12000
6 | fiat | panda | 8000
7 | fiat | 500 | 15000
8 | renault | capture | 16000
9 | renault | clio | 14000
10 | fiat | 500 | 15000
我希望通过查询了解经销商中每种类型汽车(标记和型号)的型号数量。简单来说,我会得到这样的结果:
........................................
mark | model | Quantity
........................................
fiat | 500 | 3
fiat | panda | 2
opel | astra | 1
opel | corsa | 1
renault | clio | 2
renault | capture | 1
哪个查询可以创建这样的表?
答案 0 :(得分:1)
您需要group by语句才能执行此操作。
select mark, model,count(*) as Quantity
from <tableName>
group by mark,model;