I have a table called survey_results. It has fields called item and also user_email. I have another table called business_components and it has fields called bus_comp and qualified. For each item in survey_results I want to count the number of rows in business_components where the business_components.bus_comp=survey_result.item AND business_components.qualified=”yes”. Here is what I came up with:
SELECT sr.user_email,COUNT(bc.bus_comp) FROM survey_results sr, business_components bc WHERE sr.item=bc.bus_comp AND bc.qualified=’yes’
GROUP BY sr.user_email
This seems to work and it yields this
I’d like to add another column to the result. I’d like to Count the total number of sr.item=bc.bus_comp without the bc.qualified, for each user. How can I do this?