What is wrong here?

SELECT price,AVG(downloads) FROM fake_apps group by name ,…how to correct this?

It should be like this,
First you select the price

SELECT price,

Then you want the avarge downloads,( the ROUND means it will have 2 figures after the number.(you can’t delete round too, you will need it in the next exercise)

ROUND(AVG(downloads), 2)

Without round

AVG(downloads)

And you will get it from the fake_app database, so

FROM fake_apps;

And you group it like this

GROUP BY price;

So your total code will be

SELECT price, ROUND(AVG(downloads), 2) FROM fake_apps
GROUP BY price;

Hope this helps.

1 Like

why cant we group by name?

Because if you group it by name you can’t get an avarge, imagine game called a and it have been downloaded 100 times what Avarge download do you want then? The output of the AVG will be 100 then.

If you have group by price you will get an avarge download of games in each pricing class, imagine 2 games cost €2 and game 1 is downloaded 10 times and game 2 is downloaded 30 times your AVG downloads will be 20 times, because that is the AVG downloads figures of the price class of €2.

Hope you understand it, my English is poor.

2 Likes