When you look at mySQL GROUP BY modifiers , you will find there an example with several GROUP BY columns (this is the only one official example that I found):
mysql> SELECT year, country, product, SUM(profit) -> FROM sales -> GROUP BY year, country, product; +
See how WITH ROLLUP works (you can and probably find it useful).
So, create your request as follows:
SELECT active, is_featured, COUNT(*) as cnt FROM tbl_sales GROUP BY active, is_featured WITH ROLLUP
You always need to return 4 lines that would look like this:
+--------+--------------+-----+ | active | is_feautured | cnt | +--------+--------------+-----+ | 1 | 1 | 5 | | 1 | 0 | 8 | | 0 | 1 | 0 | | 0 | 0 | 7 | +--------+--------------+-----+
And than with a simple loop (example in php, do it in what you need:
source share