This will also work as long as the table isn't large or product is
indexed.
actually,its more likely product is indexed that criteria_1 or _2...
Note: in this case when there is a tie one provider is arbitrarily
selected
select mx.product,
mx.max_criteria_1,
(select provider fro
if criteria_1 and _2 are indexed:
select
mx.product,
p1.provider as best_provider_1,
mx.max_criteria_1,
p2.provider as best_provider_2
mx.max_criteria_2
from
(select
product,
max(criteria_1) as max_criteria_1,
max(criteria_2) as max_criteria_2
from
products_provi
>
> Dear All,
>
> I have the following problem with grouping: I want to know the maximum
> in a group as well as the maximal element. Example:
>
> I have a table products_providers:
> product | provider | criteria_1 | criteria_2
>
> I have a number of products, each of them from a several