My query is shown below
select count(au.agentId), count(mr.agentId)
from agents a
left join assignunits au on au.agentId=a.id
left join assignmarketreport mr on mr.agentId=a.id
where a.adminsId='0'
and a.id='29' group BY `mr`.`agentId`, au.agentId ASC
I am getting value of count(au.agentId) same as value of count(mr.agentId).
What I want:
For the below sample data
assignunits
agentId status
2 Y
2 Y
assignmarketreport
agentId status
2 Y
2 Y
2 Y
agents
agentId adminsId
2 0
Now count(mr.agentId) should return 3
and count(au.agentId) should return 2
try this:
SQl fiddle demo