gpt4 book ai didi

mysql - Postgresql:试图获得过去十天的平均计数

转载 作者:可可西里 更新时间:2023-11-01 07:22:26 27 4
gpt4 key购买 nike

Select avg(last_10_count) AS last_10_avg
(Select count(*)
from dim_user
where effective_date ::date > current_date -10
group by effective_date ::date) AS last_10_count

当我只运行内联查询时,我得到了想要的结果,但是当我运行整个查询时它抛出以下错误:

ERROR: function avg(record) does not exist
LINE 1: Select avg(last_10_count) AS last_10_avg
HINT: NO function matches the given name and arguement types.
You might need to add explicit type casts.
************Error***************
ERROR: function avg(record) does not exit
SQL state: 42883

最佳答案

试试这个

Select avg(last_10_count) AS last_10_avg from 
(Select count(*) as last_10_count
from dim_user
where effective_date::date > current_date -10
group by effective_date :: date) Z

关于mysql - Postgresql:试图获得过去十天的平均计数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23430472/

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