I do have a table where changes are always inserted. For this purposes, a version number is increased on each insert but one version is always set manually to be the active one. I would now like to retrieve all rows where the row with the highest version does not have 'active'=true.
| UID | Version | Active | Name |
----------------------------------
| 001 | 1 | _ | Peter |
| 001 | 2 | X | Paul |
| 001 | 3 | _ | Petra |
| 002 | 1 | _ | Walt |
| 002 | 2 | X | Jan |
| 003 | 1 | X | Brad |
The result of the query should only return uid 001 as there is a max version of 3 which is not active.
I assume that I need some kind of self-join?
Thanks for any help on this!