gpt4 book ai didi

mysql - 如何对别名列表sql求和

转载 作者:行者123 更新时间:2023-11-29 04:39:59 25 4
gpt4 key购买 nike

我有查询sql

select date_format(created_at,'%Y-%m-%d') as date,
(select count(*) from tb_media where date_format(created_at,'%Y-%m-%d') = date ) as total
from tb_media group by date

结果:

enter image description here

如何求和?

最佳答案

这个查询应该有效:

select sum(a.total) from (
select date_format(created_at,'%Y-%m-%d') as date,
(select count(*) from tb_media where date_format(created_at,'%Y-%m-%d') = date ) as total
from tb_media group by date) as a

关于mysql - 如何对别名列表sql求和,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31743103/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com