Solved

Get row with max value for attribute

  • 13 December 2018
  • 3 replies
  • 67 views

Badge

I have a table with three attributes: NAME, LOCATION, and AREA. I want to get the row with the largest area, for each name. In Oracle, I can do so with this query:

 

select
    name,
    location,
    area
from (
    select
        name,
        location,
        area,
        max(area) over (partition by name) as max_area
    from mytable
)
where area = max_area

 

I could put this into a SQLExecutor, but I'd like to be able to do this even if my data source isn't Oracle.

 

 

Can I accomplish this using FME transformers instead?
icon

Best answer by erik_jan 13 December 2018, 21:33

View original

3 replies

Userlevel 2
Badge +16

The easiest way to do this:

Use Sorter to sort on attributes NAME and AREA(descending).

Use Sampler to sample the first record, group by NAME.

Badge

The easiest way to do this:

Use Sorter to sort on attributes NAME and AREA(descending).

Use Sampler to sample the first record, group by NAME.

Thanks, that worked like a charm

Userlevel 5

I agree with with @erik_jan, but an alternative solution more in tune with the orgininal question could be to use the InlineQuerier.

Reply