How to get the Max Rownumbered value, since the join key brings identical records

I am joining ten tables to my base table using an identifier field.

There is a unique field, more like ripples. This field bigintuniquely identifies each record in each table, but I cannot join this field, since it exists only in each individual table.

How can I effectively use this unique field for each table to bring only the maximum so that I can use the maximum when I have identical records?

+4
source share
1 answer

, , ( ), .

:

    SELECT bt.ID, unique_field
      FROM [basetable] bt
INNER JOIN  (SELECT MAX(unique_field) as unique_field, ID
               FROM [othertable]
           GROUP BY ID) MaxOther
ON bt.ID = MaxOther.ID 

:

ID  UNIQUE_FIELD
1   1
2   3
3   6

sql .

+1

All Articles