0

作为 MySQL/PHP Noob,我正在努力解决以下问题:

名为“汽车”的表

称为“模型”和“引擎”的字段

|Modell      |engine  
===================== 
|Volvo       |2,0  
|Volvo       |2,6  
|Volvo       |2,0  
|Saab        |1,8  
|Saab        |2,1  
|Saab        |1,8  
|Saab        |1,8  
|Chevrolet   |4,2  

想写一个问题并得到答案:

以下是:

2 volvo with 2,0 engine  
1 volvo with 2,6 engine  
3 saab with 1,8 engine  
1 saab with 2,1 engine  
1 Chevrolet with 4,2 engine  
4

3 回答 3

2
SELECT count(*) AS count,
       Modell,
       engine 
FROM cars 
GROUP BY Modell,engine
于 2013-07-05T11:01:56.500 回答
1
select modell, engine, count(*) as cnt
from cars
group by modell, engine
于 2013-07-05T11:01:31.940 回答
0

SELECT COUNT(*),Modell,ENGINE FROM cars GROUP BY modell,ENGINE

于 2013-07-05T12:58:41.877 回答