title: ERROR: missing FROM-clause entry for table "cte" while executing query in CTE
body: <p>am trying to execute the following on Postgresql</p>
  
  <p><img src="https://i.stack.imgur.com/39Vxh.jpg" alt="enter image description here"></p>
  
  <p>and am getting </p>
  
  <pre><code>    ERROR:  missing FROM-clause entry for table "cte"
  </code></pre>
  
  <p>click <a href="http://pastebin.com/TK4BdnMu" rel="nofollow noreferrer">here</a> to see my original code</p>