Skip to main content
Solved

Get row with max value for attribute

  • December 13, 2018
  • 3 replies
  • 262 views

tfcw
Participant
Forum|alt.badge.img+1
  • Participant

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?

Best answer by erik_jan

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.

View original
Did this help you find an answer to your question?

3 replies

erik_jan
Contributor
Forum|alt.badge.img+17
  • Contributor
  • Best Answer
  • December 13, 2018

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.


tfcw
Participant
Forum|alt.badge.img+1
  • Author
  • Participant
  • December 13, 2018
erik_jan wrote:

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


david_r
Evangelist
  • December 14, 2018

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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings