I have the following table structure
leads -id -fname -lname subcontractors -id -leads_id -fname -lname -status Leads can have many subcontractors. The subcontractors.status tells if the subcontractor if active or suspended
Question is how do I select leads with a count column the tells how many active and suspended subcons they have?
I have this right now:
SELECT l.id, l.fname, l.lname, s.status FROM leads l INNER JOIN subcontractors s ON l.id = s.leads_id GROUP BY l.id ORDER BY l.id DESC; My goal is to have something like this
id | fname | lname | active_subcon_count | suspended_subcon_count