I have a view that is used to generate reports every few hours. The view groups records into 5 minute intervals for display purposes. Due to the volume of data I want to restrict the number of records in each 5 minute interval.
For a report that is based on over an hour there will be 12 groups and I want to restrict the data in each group to only 100 records per group.
Ive tried using HAVING with a count on the time interval but its not restricting the total per group
Whats the best way to approach this
My view
SELECT
FROM_UNIXTIME((FLOOR((UNIX_TIMESTAMP(`r`.`created_at`) / 300)) * 300)) AS `time`,
`u`.`picture_url` ,
`u`.`username`,
`rc`.`desc` ,
`r`.`report_uid`
FROM
`records` `r`
JOIN `record_content` `rc` ON `rc`.`record_id` = `r`.`id`
JOIN `users` `u` ON `r`.`id` = `u`.`author_id`
GROUP BY `time` , `r`.`report_uid` , `u`.`picture_url` , `u`.`username` , `rc`.`desc`