I have a table that shows a full history of location ID's (LOCN\_ID), which includes an ACTIVE\_STATUS field showing A for active, or I for inactive. Each time a location's active status changes, a new record is created with a new OP\_DATE. However, any time the EXTERNALLY\_VISIBLE field in the table gets changed, another record with a new OP\_DATE is also created. 

[Here is an example of this.](https://i.stack.imgur.com/Z9AqW.png)

For each LOCN\_ID in the table, I need to be able to find the most recent OP\_DATE that the ACTIVE\_STATUS field changed (to either I or A). I don't care about when the EXTERNALLY\_VISIBLE field changed. For the LOCN\_ID shown in the example, the result should be:

```
    OP_DATE       LOCN_ID   ACTIVE_STATUS
  12/9/11 7:34     558732         I

```

There are also some cases where a LOCN\_ID's active status will have never changed, in which case the result should be the oldest OP\_DATE for that LOCN\_ID.

How would I be able to write a query in Oracle SQL to show this desired output for each LOCN\_ID?