Let\'s say I have a table with the following values.
Ford
Ford
Ford
Honda
Chevy
Honda
Honda
Chevy
So I want to construct the following outp
Hope this works for you!!
SELECT car_brand, COUNT(id) from cars
GROUP BY car_brand
COUNT(id) with InnoDB is faster than COUNT(*) because InnoDB doesn't cache the row count.
SELECT ... GROUP BY
http://dev.mysql.com/doc/refman/5.0/en/select.html
For example:
SELECT CarName, COUNT(CarName) AS CarCount FROM tbl GROUP BY CarName
select car_made, count(*) as occurrences
from cars
group by car_made
order by occurrences desc, car_made
Do you mean this?
select car_make, count(*) from cars
group by car_makes