I have a model with the fields "date" and "frequency" (Frequency is an integer). I'm trying to get the top 5 frequencies per date. Essentially I want to group by date, then get the top 5 per group.
What I have so far only retrieves the top 1 in the group:
Observation.channel("channelOne").order('date', 'frequency desc').group(:date).having('frequency = MAX(frequency)')
I want the MAX(frequency) PLUS the second, third, fourth and fifth largest PER DATE.
Sorry if this is really simple or if my terminology is off; I've just started with rails :)