title: Best way to select most recent record
body: <p>So the database I am using does not have a great way to select the most recent number by its unique ID. We have to narrow down to get the most recent record with a bunch of sub queries joining back to the original table. The original table is TBL_POL. 
  Ex.</p>
  
  <pre><code>Policy_ID   Load_DATE   ENDORSEMENT#    SEQUENCE    EXTRACTDATE
  25276       8/16/2015       0               1        8/15/2015      
  25276       2/13/2016       1               2        2/12/2016
  25276       9/24/2016       3               4        9/20/2016
  25276       9/24/2016       3               4        9/20/2016
  25276       9/24/2016       2               3        9/20/2016
  </code></pre>
  
  <p>so first we grab the max load date and join back to the original table and then grab the max endorsement # and then join back and grab the max sequence and then join back and get the max extract date to finally get back to our final record so it will be unique. Above is an example.</p>
  
  <p>Is there an easier way to do this? Someone mentioned row_number() over(partition by), but I think that just returns the whatever row number you would like. I am for a quick way to grab the most record with all these above attributes in one swipe. Does anyone have a better idea to do this, because these queries take a little while to run.</p>
  
  <p>Thanks</p>