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 

Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -