I have 2 tables, users and events:
**Users:**
usersid
age
geo_country
gender
**adbreaks:**
ts
videoid
ads_watched
geo_country
userid
My question is : For each week in January, return the ten videos that generated the most number of ads.
Am doing this code right?
SELECT video_id, COUNT(ads_watched) AS ad_watched
FROM (SELECT video_id, MAX(ads_watched) FROM adbreaks) adw
WHERE WEEK(ts) < WEEK('2017-02-01')
GROUP BY video_id
ORDER BY ad_watched DESC
LIMIT 10;
Any hint would be greatly appreciated.
Thanks,
Claudia