现在想要这样的效果:
name monthly_count total_count
a 10 20
b 15 25
name 的 monthly_count 取得方法为:
select name, count(*) as monthly_count from table_name where updated_at = yyyymm
total_count 的取得条件是:
select count(*) as total_count from table_name
即不加按月统计。
用一条SQL语句能不能实现呢?
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...