I have this query:
select
a.item_page_productid,
b.category_id,
a.viewcount
from
(select
item_page_productid,
count(*) as viewcount
from views
where eventdate > to_date(days_sub(now(), 60))
group by item_page_productid
) a
join
(select
product_id,
category_id
from catalog_products_in_categories
where active = 't') b
on a.item_page_productid=b.category_id
What I am trying to do is pair a single item_page_productid with a single category_id with the item_page_productid paired being the one with the highest viewcount.
Any ideas?