title: How to incorporate selecting by date when comparing the same attributes?
body: <p>If the record has a ‘D’ type from a operation = ‘177’ then it must have the following:
  A subsequent operation other than 097 and 190, with a the following types  (‘Y’,’S’,’T’).</p>
  
  <p>The table has a many to 1 relationship and looks like this:</p>
  
  <pre><code>ID  |   operation  |  type   |   date  
  1   |   177        |   D     |   09/12/12
  1   |   136        |   S     |   03/12/15
  2   |   177        |   D     |   04/15/13
  2   |   190        |   Y     |   05/05/14
  3   |   177        |   A     |   09/21/12
  3   |   012        |   D     |   08/12/16
  4   |   177        |   D     |   09/13/15
  4   |   122        |   T     |   11/11/11
  </code></pre>
  
  <p>In the above table, the only IDs we'd want returned are 1 (date is more recent) and 3 (operation 177 is not type D).  We wouldn't want 2, because we exclude operation 190, and we wouldn't want 4, because operation 122 date is before operation 177.</p>
  
  <p>So far, I've only been able to get to:</p>
  
  <pre><code>Select * 
  from mytable
  Where (operation = ‘177’ and type = ‘D’) 
    and ((operation not in (‘097’,’190’) and type in (‘Y’,’S’,’T’));
  </code></pre>
  
  <p>My question is, how do I select for records where the date of ((operation not in (‘097’,’190’) and type in (‘Y’,’S’,’T’))  is more recent than the date of (operation = ‘177’ and type = ‘D’)?</p>
  
  <p>Thank you.</p>