title: PostgreSQL: This type of correlated subquery pattern is not supported due to internal error
body: <p>When I press execute button, sometimes it is OK, and then I roll back and press execute button again and again, after have been made about 5 times, it show the error message: </p>
  
  <blockquote>
    <p>This type of correlated subquery pattern is not supported due to
    internal error</p>
  </blockquote>
  
  <p>My query is as follows:</p>
  
  <pre><code>WITH HyperGroup AS (
     select
        'Group Type' ::text AS mm_type
        ,'Group Name' ::text AS mm_group
  ), number1 AS (
     SELECT
        SUM(fl.flower1 +  fl.flower2 + fl.flower3 - fl.flower4) AS season
        ,'Group Type' ::text AS mm_type
        ,'Group Name' ::text AS mm_group
     FROM (x_flwr1 as fl INNER JOIN x_flwr2 as grass
     ON REPLACE(fl.flower5, ' ', '') = grass.flower6
     AND TO_DATE(fl.flower7, 'YYYY/MM/DD') &gt;= TO_DATE(CONCAT(grass.flower8, grass.flower9), 'YYYY/MM/DD')
     AND fl.flower7 = (
        SELECT MIN(fl2.flower7) FROM x_flwr1 as fl2
        WHERE TO_DATE(fl.flower7, 'YYYY/MM/DD') &gt;= TO_DATE(CONCAT(grass.flower8, grass.flower9), 'YYYY/MM/DD')
        AND  REPLACE(fl.flower5, ' ', '') = grass.flower6
        )
     )
     WHERE
        fl.flower10 != 'Flower10 Value'
     AND fl.flower10 NOT LIKE 'M%'
     AND fl.flower11 != 'Flower11 Value'
     AND fl.flower12 != 0
     AND fl.flower3 &gt; 0
  ), number2 AS (
        SELECT
           SUM(fl.flower3 - fl.flower4) AS season
           ,'Group Type' ::text AS mm_type
           ,'Group Name' ::text AS mm_group
        FROM (x_flwr1 as fl INNER JOIN x_flwr2 as grass
        ON REPLACE(fl.flower5, ' ', '') = grass.flower6
        AND TO_DATE(fl.flower7, 'YYYY/MM/DD') &gt;= TO_DATE(CONCAT(grass.flower8, grass.flower9), 'YYYY/MM/DD')
        AND fl.flower7 = (
           SELECT MIN(fl2.flower7) FROM x_flwr1 as fl2
           WHERE TO_DATE(fl.flower7, 'YYYY/MM/DD') &gt;= TO_DATE(CONCAT(grass.flower8, grass.flower9), 'YYYY/MM/DD')
           AND  REPLACE(fl.flower5, ' ', '') = grass.flower6
        ))
        WHERE
            fl.flower10 != 'Flower10 Value'
        AND fl.flower10 NOT LIKE 'M%'
        AND fl.flower11 != 'Flower11 Value'
        AND fl.flower12 != 0
        AND fl.flower3 &gt; 0
  )
  SELECT
     count(*)
  FROM
   ((HyperGroup LEFT OUTER JOIN number1 ON HyperGroup.mm_type = number1.mm_type AND HyperGroup.mm_group = number1.mm_group)
     LEFT OUTER JOIN number2 ON HyperGroup.mm_type = number2.mm_type AND HyperGroup.mm_group = number2.mm_group)
  </code></pre>
  
  <p>Thanks a lot for any suggestions.</p>