MySql sql按时间分组
select DATE_FORMAT(f.upload_time,'%Y%u') weeks,count(*),sum(p.download_times),sum(p.collection_times),sum(p.click_times) from file_base f left join file_property p on f.property_id = p.id group by weeks; select DATE_FORMAT(f.upload_time,'%Y-%m-%d') days,count(*),sum(p.download_times),sum(p.collection_times),sum(p.click_times) from file_base f left join file_property p on f.property_id = p.id group by days; select DATE_FORMAT(f.upload_time,'%Y%m') months,count(*),sum(p.download_times),sum(p.collection_times),sum(p.click_times) from file_base f left join file_property p on f.property_id = p.id group by months;
欢迎点评,共同学习,共同进步