【发布时间】:2020-06-16 20:10:36
【问题描述】:
我目前有一个使用合并的查询,该查询在 SQL Server 中有效,但在 Amazon Redshift 中无效。有没有办法我可以更合适地写这个在 Redshift 中使用:
coalesce(sum(Score)/nullif(sum(ScorePrem),0),0) as percent
【问题讨论】:
-
用
coalesce替换nullif。 -
您得到的结果有什么问题?如果您遇到错误,请分享实际的错误消息。
-
@zealous 它表明不允许嵌套聚合调用。我尝试替换 nullif,但这也没有帮助。有什么想法吗?
-
@a_horse_with_no_name 请查看已编辑的查询帖子。这是版本 PostgreSQL 8.0.2 和 Redshift 1.0.16496
-
嗯,Redshift 不是 Postgres。
标签: sql null aggregate amazon-redshift coalesce