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
posted @ 2020-06-17 15:02  小猿笔记  阅读(12812)  评论(0编辑  收藏  举报