Skip to main content

You can for example join on the aggregated table using the maximal value:

select t.* from tmp t inner join ( select max(a) max_a, b from tmp group by b ) it on t.a = it.max_a;max_a and t.b = it.b; 

Here's the db fiddle.

You can for example join on the aggregated table using the maximal value:

select t.* from tmp t inner join ( select max(a) max_a, b from tmp group by b ) it on t.a = it.max_a; 

Here's the db fiddle.

You can for example join on the aggregated table using the maximal value:

select t.* from tmp t inner join ( select max(a) max_a, b from tmp group by b ) it on t.a = it.max_a and t.b = it.b; 

Here's the db fiddle.

Source Link
Andronicus
  • 26.2k
  • 18
  • 55
  • 92

You can for example join on the aggregated table using the maximal value:

select t.* from tmp t inner join ( select max(a) max_a, b from tmp group by b ) it on t.a = it.max_a; 

Here's the db fiddle.