-1

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.

jhchee
  • 3
  • 5
  • 1
    This is identical to your last question, which was closed as a duplicate... if you don't think it was a duplicate add a comment. Don't delete and ask again. – Dale K May 19 '22 at 08:22
  • 1
    Probably you need [row_number()](https://docs.microsoft.com/en-us/sql/t-sql/functions/row-number-transact-sql?view=sql-server-ver15) – Squirrel May 19 '22 at 08:29

0 Answers0