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