title: PostgreSQL:how to update rows in CTE
body: <p>am running <code>PostgreSQL 9.2</code>.
  <br>below given is a sample of my <em>huge and ugly</em><code>query</code> </p>
  
  <pre><code>with cte as(
  select ....... from aTable 
  ),cte1 as (
  select ..... from bTable inner join cte using(anID)
  ),update_cte as(
  update cte set aField=(select somthing from cte1)
  )
  select * from cte
  </code></pre>
  
  <p><br> i need to create a <code>view</code> with the final <em>result</em>.</p>
  
  <p>while executing the above am getting an error which is below.</p>
  
  <pre><code>ERROR:  relation "cte" does not exist
  </code></pre>
  
  <p>I know am doing something bad.<br>hope you can understand what am trying to achieve from the above <em>query</em>.
  <br>So please suggest any alternative method for it.</p>
  
  <p>Replies are much appreciated.</p>
  
  <p>Note : <a href="http://pastebin.com/UX4sYi3f" rel="noreferrer">the actual query</a></p>