Here I have shared my query. All the total values are giving wrong results as very big value numbers which are not the desired COUNT values. Whats wrong in my query ?
SELECT bd.business_id,
bd.business_name,
bd.business_address,
bd.created_at,
bd.updated_at AS extent_expiry_date,
bd.manager_id as user_id,
COUNT(m.manager_id) AS total_managers,
COUNT(a.agent_id) AS total_agents,
COUNT(c.customer_id) AS total_customers,
COUNT(t.task_id) AS total_tasks,
COUNT(t.order_id) AS total_orders
FROM business_details bd
LEFT JOIN managers m ON m.business_id = bd.business_id
LEFT JOIN agents a ON a.business_id = bd.business_id
LEFT JOIN customers c ON c.business_id = bd.business_id
LEFT JOIN tasks t ON t.business_id = bd.business_id
GROUP BY bd.business_id
business_id? If not then if a business has 3 managers and 3 agents you're getting 9 rows... have you looked at the raw data for a single business to determine if you're selecting the data that you want?