SELECT `p1`.`usrid` AS `usrid`, COUNT(*) AS `cnt`,
`p1`.`data` AS `data`
FROM `posts` AS `p1`
JOIN `posts` AS `p2` ON `p1`.`usrid` = `p2`.`usrid` AND `p1`.`usrid` =5
AND `p2`.`data` BETWEEN `p1`.`data`
AND `p1`.`data`+INTERVAL 1 HOUR
WHERE `p1`.`usrid` = 5
GROUP BY `p1`.`postid`
SELECT *
FROM (
SELECT `p1`.`usrid` AS `usrid`, COUNT(*) AS `cnt`,
`p1`.`data` AS `data`
FROM `posts` AS `p1`
JOIN `posts` AS `p2` ON `p1`.`usrid` = `p2`.`usrid`
AND `p2`.`data` BETWEEN `p1`.`data`
AND `p1`.`data`+INTERVAL 1 HOUR
GROUP BY `p1`.`postid`
ORDER BY `cnt` DESC
LIMIT 10
) AS `t1`
JOIN `posts` AS `t2` ON `t1`.`usrid` = `t2`.`usrid` AND `t1`.`usrid` = 5
AND `t2`.`data` BETWEEN `t1`.`data`
AND `t1`.`data`+INTERVAL 1 HOUR
ORDER BY `t1`.`cnt`, `t1`.`usrid`, `t2`.`data`
Да, попробовал гугл и та же лажа. Спасибо за тест!