Say I have the following tables:
|RefNumber| Charge| IssueDate| ------------------------------ | 00001| 40.0|2009-01-01| | 00002| 40.0|2009-06-21| |ID|RefNumber|Forename| Surname| --------------------------------- 1| 00001| Joe| Blogs| 2| 00001| David| Jones| 3| 00002| John| Smith| 4| 00002| Paul| Walsh|
I would like to select refnumber, charge and issuedate from the first table then join on refnumber to the second table to retrieve forename and surname but only get the row with the highest id.
So results would look like:
|RefNumber| Charge| IssueDate|ID|Forename| Surname| ----------------------------------------------------- | 00001| 40.0|2009-01-01| 2| David| Jones| | 00002| 40.0|2009-06-21| 4| Paul| Walsh|
I am unsure who to limit results on the join to only return the record with the highest ID from the second table.