title: ERROR: subquery in FROM cannot refer to other relations of same query level
body: <p>I'm working with PostgreSQL 9 and I want to find the nearest neighbor inside table <code>RP</code> for all tuples in <code>RQ</code>, comparing the dates (<code>t</code>), but I get this error:</p>
  
  <blockquote>
    <p>ERROR: subquery in FROM cannot refer to other relations of same query
    level</p>
  </blockquote>
  
  <p>using this query:</p>
  
  <pre><code>SELECT *
  FROM RQ, (SELECT * FROM RP ORDER BY ABS(RP.t - RQ.t) LIMIT 1) AS RA
  </code></pre>
  
  <p><code>RQ.t</code> in subquery seems to be the problem. How can I avoid this error? How can I get access from subquery to <code>RQ</code>?</p>