SQL Server 2012 Enterprise: Cannot perform an aggregate function on an expression containing an aggregate or a subquery? -
i'm trying write query finds brand id, brand name, brand type , average price of products brand has largest average product price. here's i've got:
select lgbrand.brand_id, brand_name, brand_type, max(avg(prod_price)) avgprice lgproduct, lgbrand group lgbrand.brand_id, brand_name, brand_type order avgprice desc
i'm new sql. before had same code without "max" command, brought average brands in output.
not sure go.
won't top 1 give want?
select top 1 lgbrand.brand_id, brand_name, brand_type, avg(prod_price) avg_prod_price lgproduct, lgbrand group lgbrand.brand_id, brand_name, brand_type order avg_prod_price desc
Comments
Post a Comment