Skip to main content
Solved

Get row with max value for attribute

  • December 13, 2018
  • 3 replies
  • 334 views

tfcw
Contributor
Forum|alt.badge.img+1

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.

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

3 replies

erik_jan
Contributor
Forum|alt.badge.img+26
  • 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
Contributor
Forum|alt.badge.img+1
  • Author
  • Contributor
  • 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.

Thanks, that worked like a charm


david_r
Celebrity
  • 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.