title: Inner join most recent row
body: <p>I've got 2 tables I need to join for a select statement which should give me only the last row for each sensorID (the most recent value of every sensorID). Here are my tables:</p>
  
  <pre><code>sensorID| Name | Description |   stationID
  ---------------------------------
  1 |  Name1   |  Desc1   | 2
  2 |  Name2   |  Desc2   | 1
  3 |  Name3   |  Desc3   | 3
  4 |  Name4   |  Desc4   | 2
  </code></pre>
  
  <p>Values</p>
  
  <pre><code>vID | sensorID | Date | Time |  value
  ---------------------------------
  1 |  1   |  2016-12-29   | 15:08:00 | 0.2
  2 |  1   |  2016-12-29   | 15:10:00 | 0.21
  3 |  1   |  2016-12-29   | 15:12:00 | 0.4
  4 |  4   |  2016-12-29   | 15:14:00 | 12.2
  </code></pre>
  
  <p>I tried running the following:</p>
  
  <pre><code>SELECT * FROM H INNER JOIN Values V ON H.sensorID = V.sensorID WHERE H.stationID = 2;
  </code></pre>
  
  <p>Which produced these results:</p>
  
  <pre><code>sensorID | Name | Description | stationID | vID | sensorID | Date   | Time     | value
  1    | Name1|  Desc1      | 2         | 1   |    1     |2016-12-29  | 15:08:00 | 0.2
  1    | Name1|  Desc1      | 2         | 2   |    1     |2016-12-29  | 15:10:00 | 0.21
  1    | Name1|  Desc1      | 2         | 3   |    1     |2016-12-29  | 15:12:00 | 0.4
  4    | Name4|  Desc4      | 2         | 4   |    1     |2016-12-29  | 15:14:00 | 12.2
  </code></pre>
  
  <p>But I am looking for this output:</p>
  
  <pre><code>sensorID | Name | Description | stationID | vID | sensorID | Date   | Time     | value
  1    | Name1|  Desc1      | 2         | 3   |    1     |2016-12-29  | 15:12:00 | 0.4
  4    | Name4|  Desc4      | 2         | 4   |    1     |2016-12-29  | 15:14:00 | 12.2
  </code></pre>