使用COUNT(不同的XXX)时的RedShift错误错误:XX000:由于内部错误,不支持这种类型的相关子查询模式

时间:2019-09-26 12:07:31

标签: sql amazon-redshift aginity

我有一个通过Aginity在RedShift中运行的小查询,它收到以下错误:

  

错误:XX000:由于内部错误,不支持这种类型的相关子查询模式

当前查询:

SELECT 'MYSCHEMA.MYTABLE.FIELDA' as obj_name,
COUNT(*) as rows, 
COUNT(DISTINCT FIELDA) as distinct_vals, 
SUM(CASE WHEN FIELDA in ('00DK','00DC','00DE','00DD','00DB') THEN 1 ELSE 0 END) as enter, 
SUM(CASE WHEN TRIM(FIELDA) IN ('',null) THEN 1 ELSE 0 END) as nulls 
FROM MYSCHEMA.MYTABLE

但是,如果我删除DISTINCT,它将运行:

SELECT 'MYSCHEMA.MYTABLE.FIELDA' as obj_name,
COUNT(*) as rows, 
COUNT(FIELDA) as distinct_vals, 
SUM(CASE WHEN FIELDA in ('00DK','00DC','00DE','00DD','00DB') THEN 1 ELSE 0 END) as enter, 
SUM(CASE WHEN TRIM(FIELDA) IN ('',null) THEN 1 ELSE 0 END) as nulls 
FROM MYSCHEMA.MYTABLE

1 个答案:

答案 0 :(得分:1)

如果在子查询中使用窗口函数,是否可以正常工作?

<dependency>
    <groupId>com.fasterxml.jackson.module</groupId>
    <artifactId>jackson-module-parameter-names</artifactId>
    <version>${jackson.version}</version>
</dependency>