I have 2 tables.
books (id, sku, name, description, date_added)
and
books_views (id, sku, date_viewed)
I am trying to write an optimized query to do the following.
- To find the most viewed books for the last week
- To find the most viewed books for the last month
The books_views table has more than 4 million entries. What would be the best way to get the data sorted by views for week and month?
books_viewsfor each view.