This might be easier to explain with the code first, so I'm currently using something that looks like this:
'A' in
(
SELECT DISTINCT b.col1
FROM table b
WHERE b.ky1 = a.ky1
AND b.ky2 = a.ky2
AND b.group = a.group
AND b.rowNum < a.rowNum
)
in a where clause. Essentially I'm trying to see if A is a value at any point prior to a row specified by the outer query. This works on its own. The issue is when I add the following to the query:
OR
'S' in
(
SELECT DISTINCT b.col1
FROM tableb b
WHERE b.ky1 = a.ky1
AND b.ky2 = a.ky2
AND b.group = a.group
AND b.rowNum < a.rowNum
)
Now, Netezza produces the following error message:
ERROR: (2) This form of correlated query is not supported - consider rewriting
I have a feeling the only way around this would be to do some sort of join, but I'm not exactly sure how to do that without producing a lot of duplicates. Any suggestions?