I have a following sql query which run at:
PostgreSQL 9.5.1, compiled by Visual C++ build 1800, 64-bit
but not at:
PostgreSQL 8.2.15 (Greenplum Database 4.3.5.4 build 1) on x86_64-unknown-linux-gnu, compiled by GCC gcc (GCC) 4.4.2
SELECT id,
(SELECT AVG(dur)
FROM data t
WHERE t.id = t1.id AND
t.id IN (SELECT id
FROM data t2
WHERE t2.id = t1.id
ORDER BY dur
DESC LIMIT 10)) as avgdur
FROM data t1
WHERE t1.b<10000
ORDER BY avgdur
DESC LIMIT 1;
I get the following error: ERROR: correlated subquery with skip-level correlations is not supported (subselect.c:394)
How should i modify the query?
WHERE t2.id = t1.id)) as avgdur-->>WHERE t2.id = t.id)) as avgdurBut the query can probably be simplified.