All pastes #69439 Raw Edit

Mine

public sql v1 · immutable
#69439 ·published 2006-06-22 22:32 UTC
rendered paste body
insert into analytics.ld_cat_det (date, content_id, category_id, parent_category_id, content_views, video_views, picture_views, audio_views);select a.stats_day date,a.content_id  ,c.category_id,d.parent_category_id,sum(a.unique_views) as content_views,sum(if(b.content_type='VIDEO',a.unique_views,0)) video_views,sum(if(b.content_type='PICTURE',a.unique_views,0)) picture_views,sum(if(b.content_type='AUDIO',a.unique_views,0)) audio_views from virv.CONTENT_VIEW_STATS a, virv.CONTENT b, (select content_id, category_id from virv.CONTENT_CATEGORIZATION group by content_id)c, virv.CATEGORIES dwhere a.content_id = b.content_id and a.content_id = c.content_idand b.content_id = c.content_idand c.category_id = d.category_idand date(a.stats_day) = subdate(curdate(),1)group by a.stats_day ,a.content_id  ,c.category_id ,d.parent_category_id