I am trying to do a query across two tables and then refine the results to only provide the most recent record based on the greatest time value for each sequence\_id.

I've tried many combinations of GROUP BY, ORDER BY, Max(), PARTITION and other suggestions found on SO. Unfortunately, all the solutions I have seen so far only use one table and only return the pair of columns of interest.

Queries I have attempted:

```sql
select a.trip, a.sequence_id, a.time, a.point_id 
from th, ti as a
     inner join (
        select th.trip, max(ti.sequence_id), ti.time, ti.point_id
        from th, ti 
        group by th.trip
     ) as g on g.sequence_id = a.sequence_id

select th.trip, ti.sequence_id, ti.time, ti.point_id 
FROM th, ti 
where ti.sequence_id = th.sequence_id 
AND (row_number() over (partition by th.sequence_id) = 1)

```

Given the tables 'th’ and 'ti'

![Table 'th'](https://i.stack.imgur.com/2MAAa.png)

![Table 'ti'](https://i.stack.imgur.com/e0Xei.png)

I need a query that will return ONLY the rows highlighted where for that sequence\_id where the time value is greatest.

[Result](https://i.stack.imgur.com/jZUk7.png)

We are using an Oracle database.

I've researched many posts on SO regarding this topic, but could not find any that used multiple tables and returned results for other columns an addition to the value/pair columns.