SELECT COUNT(gr_companies.id) AS count FROM gr_companies LEFT JOIN xposts ON xposts.id=gr_companies.cat_id LEFT JOIN users ON users.id=gr_companies.user_id WHERE gr_companies.comp_id_place= AND gr_companies.is_enabled=1 AND gr_companies.is_blocked=0 AND ((gr_companies.date2 IS NOT NULL and gr_companies.data_time_end>='2024-12-22 13:09:15' ) OR (gr_companies.date2 IS NULL and gr_companies.data_time_start>='2024-12-22 13:09:15' ))