Report question

Question: how to optimize mysql query : counting category and subcategory with single Query from two tables