Practice #13 Return the total number of apps for the business category


#1

Hey everyone, been scratching my head on this one, this is the closest I can get:

SELECT category, SUM(downloads) FROM fake_apps
GROUP BY category;

This doesn't specifically show just the business category though, is there a way to single that out?

Thanks in advance guys.


#2

SELECT category, SUM(downloads) FROM fake_apps WHERE category = 'Sports' AND 'Health & Fitness' ;

produces the output of

Query Results
category SUM(downloads)

But no results.

If we modify the above statement to

 SELECT category, SUM(downloads)  FROM fake_apps WHERE category = 'Sports' OR 'Health & Fitness';

we get

Query Results
category SUM(downloads)
Sports 176988

And if we reverse the order of the categories:

SELECT category, SUM(downloads)  FROM fake_apps WHERE category =  'Health & Fitness' OR 'Sports';

Query Results
category SUM(downloads)
Health & Fitness 165555

So I'm stumped too...


#3

Ok, answered my own question, I was using the wrong command, should be:

SELECT category, COUNT(downloads) FROM fake_apps
WHERE category = 'Music';


#5

OK, sorry I was working on #21. But you should not be using COUNT(downloads), try SUM(downloads):

SELECT category, SUM(downloads) FROM fake_apps WHERE category = 'Music';

#7