I am looking to select the following rows from a table where the following constraints are met:

I have been messing with joins on itself (selecting max version of this if idb = x in a subquery) but have had no luck

For example:

idb = x
if va of a specific ida is the max va for that ida and idb is x, then include it

```
ida     |    idb     |     va
--------------------------------
abc          x             1
abc          y             2
abc          x             3
def          x             1
xyz          x             1
xyz          x             2
xyz          z             3

```

Result:

```
ida     |    idb     |     va
--------------------------------
abc          x             3
def          x             1

```

For the previous example, 

abc is included because the highest version of va (3) is in a row where idb=x

def is included because the highest version of va(1) is in a row where idb = x

xyz is NOT included because the highest version of xyz (va=3) has a value of idb=z