title: How to select records with maximum values in two columns?
body: <p>It was hard to come up with an understandable title for this question.
  I'll try to explain with an example.</p>
  <p>First I had a simple table <code>INFO</code> in Oracle DB:</p>
  <pre><code>year      type      message
  ----      ----      -------
  2001      1         cakes are yammy
  2003      2         apples are dangerous
  2012      2         bananas are suspicious
  2005      3         cats are tricky
  </code></pre>
  <p>And I need to select newest messages of certain types (for example <code>type = 1</code> or <code>type = 2</code>):</p>
  <pre><code>2001      1         cakes are yammy
  2012      2         bananas are suspicious
  </code></pre>
  <p>So I used the query:</p>
  <pre><code>select * from INFO i 
  where year = (select max(year) from INFO i_last where i.type = i_last.type) 
  and i.type in (1, 2)
  </code></pre>
  <p>But now I need to add a new &quot;quarter&quot; column to my INFO table. And select the newest records by year and quarter.</p>
  <pre><code>year      quarter      type      message
  ----      -------      ----      -------
  2001      2            1         cakes are yammy
  2012      3            2         onions are cruel
  2012      1            2         bananas are suspicious
  2005      1            3         cats are tricky
  </code></pre>
  <p>The newest records with type 1 or 2 will be:</p>
  <pre><code>2001      2            1         cakes are yammy
  2012      3            2         onions are cruel
  </code></pre>
  <p>How should such query look like?</p>