dimanche 4 octobre 2015

Highest Number of Occurences without using Limit

So I searched this topic a lot and I have it working so it gets THE highest number of occurrences, but I want to make the SQL grab an arbitrary amount (in case there are multiple values with the highest amount). Right now I have:

SELECT houses.cars, COUNT(houses.cars) as Numb 
FROM houses 
Group By houses.cars Order By Numb Desc 
Limit 1;

which returns THE highest number of occurrences, but for example if there are 2 types of cars with 8 occurrences I want it to return both of them.

I know this is how you do it when you want the highest values when they're durations (integers):

SELECT times.duration AS 'Hour', 
FROM times WHERE times.duration>=(                                                                          
SELECT MAX(times.duration)  FROM times);

but anytime I try to do similar logic with COUNT it gives syntax errors. Thanks in advancefor any help.

Aucun commentaire:

Enregistrer un commentaire