mysql 根据多个不同字段进行分组,并统计总数,求和

select t_date,type,sum(price) as total_price,count(*) as news_count from
(select date_format(log_time,'%Y-%m-%d') as t_date,type,price from test_1 ) as temp
where 1=1 group by t_date,type;
select date_format(log_time,'%Y-%m-%d') as t_date,type,sum(price) as total_price,count(*) as news_count from test_1 where 1=1
group by t_date,type
原文地址:https://www.cnblogs.com/KillBugMe/p/13152484.html