title: Need help creating a view on top of a JOIN query that needs to return only the latest value
body: <p>I need help with my SQL Query I have Two tables that i need to join using a LEFT OUTER JOIN, then i need to create a database view over that particular view. If i run a query on the join to look for name A i need to get that A's latest brand "AP". 
  Table 1</p>
  
  <pre><code>ID     name     address
  -----------------------  
  1      A         ATL
  2      B         ATL
  </code></pre>
  
  <p>TABLE 2</p>
  
  <pre><code>ID     PER_ID    brand      DATEE
  --------------------------------------------
  1      1         MS           5/19/17:1:00pm
  2      1         XB           5/19/17:1:05pm
  3      1         AP           5/19/17:2:00pm
  4      2         RO           5/19/17:3:00pm
  5      2         WE           5/19/17:4:00pm
  </code></pre>
  
  <p>I tried query a which returns correct result but i get problem 1 when i try to build the database view on top of the join. I tried query b but when i query my view in oracle sql developer i still get all the results but not the latest.</p>
  
  <p>query a:</p>
  
  <pre><code>SELECT * from table_1
  left outer join table_2 on table_1.ID = Table_2.PER_ID
  AND table_2.DATE = (SELECT MAX(DATE) from table_2 z where z.PER_ID = table_2.PER_ID)
  </code></pre>
  
  <p>Problem 1</p>
  
  <pre><code>Error report -
  ORA-01799: a column may not be outer-joined to a subquery
  01799. 00000 -  "a column may not be outer-joined to a subquery"
  *Cause:    &lt;expression&gt;(+) &lt;relop&gt; (&lt;subquery&gt;) is not allowed.
  *Action:   Either remove the (+) or make a view out of the subquery.
             In V6 and before, the (+) was just ignored in this case.
  </code></pre>
  
  <p>Query 2:</p>
  
  <pre><code>SELECT * from table_1
      left outer join(SELECT PER_ID,brand, max(DATEE) from table_2 group by brand,PER_ID) t2 on table_1.ID = t2.PER_ID
  </code></pre>