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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM