Fake Apps question #20


#1

The question is:

Return the total number of downloads for apps belonging to the Sports or Health & Fitness category.

In previous questions I was able to do the same for a single category, e.g.:

SELECT category, SUM(downloads) FROM fake_apps WHERE category is "Business";

But here I must combine two categories together. So I guess that I must use GROUP BY and then filter the results. But the following:

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

is not correct, as it returns only the total of the first category after the IS clause (you can check the correct number per each category by running the above query without the WHERE clause).

What's the right way to make this query?
Thanks in advance


#2

Ok, I found the right query:

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

Easier than I thought.


#3

Or it can also be:

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


#5