I used 2 Tables because my version number is in a different table than my object.
select Title, t1.Stage, max(t2.Version) as Version
from Table1 t1
inner join Table2 t2 on t2.Stage = t1.Stage
group by Title, t2.Version, t1.Stage
Results that I am getting
| Title | Stage | Version |
|---|---|---|
| D1 | ACTIVE | 2 |
| D1 | NON-ACTIVE | 1 |
| D2 | ACTIVE | 2 |
| D2 | NON-ACTIVE | 1 |
| D3 | ACTIVE | 2 |
| D3 | NON-ACTIVE | 1 |
| D3 | STOPPED | 3 |
Results that I am trying to get
| Title | Stage | Version |
|---|---|---|
| D1 | ACTIVE | 2 |
| D2 | ACTIVE | 2 |
| D3 | STOPPED | 3 |
How do I make the edit for the max(), I used 2 Tables because my version number is in a different table than my object. I tried using the rownumber method but does not work as I am using 2 tables.