【问题标题】:syntax error using redshift listagg function使用 redshift listagg 函数的语法错误
【发布时间】:2021-07-26 18:06:34
【问题描述】:
select id, listagg(timestamp,',') 
within group (order by timestamp) as timestamp 
from activity group by contact_id order by contact_id limit 1;

这是我得到的错误:

syntax error at or near ","
LINE 1: select eloqua_contact_id, listagg(timestamp,',') within grou...

这个查询有什么问题吗?当我删除分隔符选项时,我没有收到错误,一切都恢复正常。如何添加逗号来分隔列表 agg 列?

【问题讨论】:

    标签: amazon-redshift


    【解决方案1】:

    我怀疑问题出在列名“时间戳”上,因为它是一种数据类型和保留字。如果将列名括在双引号中,它将防止它被解释为数据类型。 (最佳猜测)

    select id, listagg("timestamp",',') 
    within group (order by "timestamp") as "timestamp" 
    from activity group by contact_id order by contact_id limit 1;
    

    将列命名为与数据类型相同通常不是一个好主意。

    【讨论】:

    • 谢谢,原来如此!感谢您指出不将列命名为与数据类型相同的提示:) 接受了这个答案。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-22
    • 1970-01-01
    • 2015-12-23
    • 1970-01-01
    相关资源
    最近更新 更多