title: Oracle correlated subquery in FROM list
body: <p>I just tried to do a correlated subquery in the <code>FROM</code> clause of a <code>SELECT</code> statement in Oracle, but I was given an error indicating that I couldn't do the correlation (something to the effect that <code>Obs.pID</code> was not recognized). </p>
  
  <p>Should this work?</p>
  
  <pre><code>FROM ml.Person Person 
      JOIN ml.Obs ON Person.pID = Obs.pId
          JOIN (SELECT ObsMax2.pId, ObsMax2.hdId
                  , MAX(ObsMax2.obsDate) as maxDate
                  FROM ml.Obs ObsMax2
                  WHERE ObsMax2.pId = Obs.pId
                      AND ObsMax2.obsDate &lt; {?EndDate}
                  GROUP BY ObsMax2.pId, ObsMax2.hdId) ObsMax 
              ON Obs.pId = ObsMax.pId
                  AND Obs.hdId = ObsMax.hdId
                  AND Obs.obsDate = ObsMax.maxDate
  </code></pre>
  
  <p>My workaround would appear to be to make it a non-correlated subquery, and add criteria to the subquery that keeps it from running completely amuck, amuck, amu--<em>oof</em> Sorry. </p>
  
  <p>I'd rather figure out how to properly correlate it, though, if possible - the view that works like that subquery takes forever to build.</p>