select cat_microcategories.*, (SELECT count(task_id) FROM prd_tr_tasks WHERE prd_tr_tasks.category_id = cat_categories.category_id ) as num_requests from `cat_microcategories` inner join `cat_categories` on `cat_microcategories`.`category_id` = `cat_categories`.`category_id` inner join `cat_macros` on `cat_categories`.`macro_id` = `cat_macros`.`macro_id` inner join `prd_microcategory_settings` on `prd_microcategory_settings`.`microcategory_id` = `cat_microcategories`.`microcategory_id` inner join `seo_lptaskers` on `seo_lptaskers`.`microcategory_id` = `cat_microcategories`.`microcategory_id` where `location_display` = 1 and `cat_macros`.`macro_id` = 46 and `cat_microcategories`.`microcategory_id` != 42 and `seo_lptaskers`.`distrito` = madrid and `seo_lptaskers`.`concelho` = madrid and `prd_microcategory_settings`.`district_seo` = madrid and `prd_microcategory_settings`.`concelho_seo` = madrid and `prd_microcategory_settings`.`enabled` = 1 and (char_length(seo_lptaskers.global_description)>149 or char_length(seo_lptaskers.description)>149) and char_length(seo_lptaskers.title) and `seo_lptaskers`.`visibility` in (0, 4) group by `cat_microcategories`.`microcategory_id` order by `num_requests` desc, `cat_microcategories`.`microcategory_name` asc limit 20