mySQL statment count of post in each category and sub category

You may try this amateur code.

SELECT  COUNT(ID)
FROM wp_posts  
LEFT JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) 
WHERE 1=1  
AND ( 
  wp_term_relationships.term_taxonomy_id IN (1)
) 
AND wp_posts.post_type="post" 
AND ((wp_posts.post_status="publish")) 
GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC

Note the term_taxonomy_id IN (1) is where your category ID is 1.
You may remove the line for published posts, so it will get any post.

You just need to run this code for any category you have.