由于内部错误,不支持相关子查询模式 - 其中不存在相关子查询
Correlated subquery pattern is not supported due to internal error - where not exists correlated subquery
我有一个查询给出了上述错误。我的代码如下:
SELECT *,
dense_rank() OVER (PARTITION BY email
ORDER BY priority_score,
comp) AS r
FROM main_query
WHERE NOT EXISTS
(SELECT name,
event,
email,
report_date
FROM gm
WHERE gm.name= main_query.name
AND gm.event= main_query.event
AND gm.email = main_query.email
AND gm.report_date >= (CURRENT_DATE - 25)::date)
ORDER BY priority_score ASC
我看到克服这些类型错误的一种解决方案是能够在不相关的查询 (sherlock) 中转换相关的子查询。因此,我正在寻找其他使用 where not exists
语句但没有相关子查询的方法,即在子查询 ((...) from gm left join main_query on
(...))。有谁知道这是否可行以及如何实现?
非常欢迎任何建议,非常感谢!
LEFT JOIN
版本有效吗?
SELECT mq.*,
dense_rank() OVER (PARTITION BY mq.email
ORDER BY mq.priority_score, comp
) AS r
FROM main_query mq LEFT JOIN
gm
ON gm.name = mq.name AND
gm.event= mq.event AND
gm.email = mq.email AND
gm.report_date >= (CURRENT_DATE - 25)::date)
WHERE gm.name IS NULL
ORDER BY priority_score ASC;
如果这不起作用,它应该像这样工作:
SELECT mq.*,
dense_rank() OVER (PARTITION BY mq.email
ORDER BY mq.priority_score, comp
) AS r
FROM main_query mq LEFT JOIN
(SELECT gm.*
FROM gm
WHERE gm.report_date >= (CURRENT_DATE - 25)::date)
) gm
ON gm.name = mq.name AND
gm.event= mq.event AND
gm.email = mq.email
WHERE gm.name IS NULL
ORDER BY priority_score ASC
我有一个查询给出了上述错误。我的代码如下:
SELECT *,
dense_rank() OVER (PARTITION BY email
ORDER BY priority_score,
comp) AS r
FROM main_query
WHERE NOT EXISTS
(SELECT name,
event,
email,
report_date
FROM gm
WHERE gm.name= main_query.name
AND gm.event= main_query.event
AND gm.email = main_query.email
AND gm.report_date >= (CURRENT_DATE - 25)::date)
ORDER BY priority_score ASC
我看到克服这些类型错误的一种解决方案是能够在不相关的查询 (sherlock) 中转换相关的子查询。因此,我正在寻找其他使用 where not exists
语句但没有相关子查询的方法,即在子查询 ((...) from gm left join main_query on
(...))。有谁知道这是否可行以及如何实现?
非常欢迎任何建议,非常感谢!
LEFT JOIN
版本有效吗?
SELECT mq.*,
dense_rank() OVER (PARTITION BY mq.email
ORDER BY mq.priority_score, comp
) AS r
FROM main_query mq LEFT JOIN
gm
ON gm.name = mq.name AND
gm.event= mq.event AND
gm.email = mq.email AND
gm.report_date >= (CURRENT_DATE - 25)::date)
WHERE gm.name IS NULL
ORDER BY priority_score ASC;
如果这不起作用,它应该像这样工作:
SELECT mq.*,
dense_rank() OVER (PARTITION BY mq.email
ORDER BY mq.priority_score, comp
) AS r
FROM main_query mq LEFT JOIN
(SELECT gm.*
FROM gm
WHERE gm.report_date >= (CURRENT_DATE - 25)::date)
) gm
ON gm.name = mq.name AND
gm.event= mq.event AND
gm.email = mq.email
WHERE gm.name IS NULL
ORDER BY priority_score ASC