<p>If I have records:</p>

<pre>
Row  Date,        LocationID, Account
1    Jan 1, 2008  1           1000
2    Jan 2, 2008  1           1000
3    Jan 3, 2008  2           1001
4    Jan 3, 2008  1           1001
5    Jan 3, 2008  3           1001
6    Jan 4, 2008  3           1002
</pre>

<p>I need to get the row (<code>date</code>, <code>locatinid</code>, <code>account</code>) where the row has the most recent date for each distinct <code>locationid</code>:</p>

<pre>
4    Jan 3, 2008  1           1001
3    Jan 3, 2008  2           1001
6    Jan 4, 2008  3           1002
</pre>

Try something like:
```
```
select *
from mytable t1
where date = (select max(date) from mytable t2
              where t2.location = t1.location);
```
```