小编DUn*_*wn1的帖子

Postgresql:尝试获得过去10天的平均值

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
Run Code Online (Sandbox Code Playgroud)

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

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
Run Code Online (Sandbox Code Playgroud)

mysql sql database postgresql

5
推荐指数
1
解决办法
6020
查看次数

编写一个查询来选择用单引号括起来的列

我正在尝试编写一个选择查询,该查询应返回用单引号括起来的列值。假设列 (ABC) 有

Values: 123
        567
Run Code Online (Sandbox Code Playgroud)

查询应返回

Output: '123'
        '567'
Run Code Online (Sandbox Code Playgroud)

sql postgresql quoting

2
推荐指数
1
解决办法
7439
查看次数

标签 统计

postgresql ×2

sql ×2

database ×1

mysql ×1

quoting ×1