mysql - How to show column name and nested aggregation result -
i want nested aggregation can choose whether aggregate max, min, or avg of nested avg aggregation. i want result this: (genre, max or min or avg of nested avg) current have nested aggregation query returns maximum average price of genre, can't seem select genre corresponding maximum. consider table games(gameid, gamename, genre, price) , disregard gameid , gamename. the nested query have right now: select max(avggenreprice) maxavg ( select genre subgenre, avg(price) avggenreprice games group subgenre ) sub; example result of query: |maxavg| | 368.22| i want this | genre | maxavg | | racer | 368.22 | ive tried : select sub.subgenre, max(avggenreprice) maxavg ( select genre subgenre, avg(price) avggenreprice games group subgenre ) sub ; but gives me error code 1140 select top 1 subgenre genre , avg (price) maxavg games group subgenre order avg (price) desc