mysql - SQL: Finding Maximum of Averages with related field -


I have a problem getting the max of the average with respect to the field ( provider_state ).

I have a table that has average_user_payment field for payment. There is also a state field in the form of provider_state in each row with the question below I'm getting average of average but I can not find the relevant provider_state .

Its main objective is to give me the name of that position, in which the average of the maximum payment is paid along with the amount of the payment. Select the provider_state, max (average) maximum max_average from (SELECT provider_state, AVG (average_usable_payment) encoding by average amplifier_set by '% $ search%' Like Digg_defination of the group) ABC

Please suggest me what is the best way to get related field as well?

If you have a question, "name me the state, whose maximum payment is average, with the payment amount . "After that you can solve it like this:

  select provider_state, the average (average_comparable_payment) genomic as the average where the '% $ search%' group-like provider_state ORDER Average range described by 1;  

Comments