I have the following mysql query
select a.agency_name, a.green ,b.red, c.amber
from (select count(action_status) as green, agency_name from tbl_actions
where action_status='In Progress' group by agency_name) a
join (select count(action_status) as red, agency_name from tbl_actions
where action_status='Delayed' group by agency_name) b on a.agency_name=b.agency_name
join (select count(action_status) as amber, agency_name from tbl_actions
where act_status='Completed' group by agency_name) c on a.agency_name=c.agency_name
and it is returning blank values as
I do have these fields in the db populated with relevant data.
Conditional aggregation is much simpler:
A self-join is not necessary. The reason you are getting no rows in the result set is because no agency has all three statuses.