I have a MySQL table "page" that contains fields "page_name" and "page_timestamp". The table stores page and times requests that were made on a website. I'm trying to write a query that gives me the most hit page for every 5 min period.
Output like
Time Page Hits
12:00 index.html 34
12:05 page1.html 11
12:10 index.html 44
This is one attempt, but no output.
select pages_timestamp,
(select count( pages_name)
from pages t2
where UNIX_TIMESTAMP(t2.pages_timestamp) DIV 300 =
UNIX_TIMESTAMP(pages_timestamp)
group by pages_name
order by count(pages_name) desc
limit 1 )
from pages
where ...
group by UNIX_TIMESTAMP(pages_timestamp ) DIV 300
I'm sure there is a better approach