I need to find the percentage of companies that are based in the USA, but having issues with the calculation
company(tbl1) has the following fields:
company_id
company_name
company_type
country_code
company_locations(tbl2) has the following fields:
company_id
country_code
company_location_id
My code:
SELECT company_name, COUNT(company_id) *100/(SELECT COUNT(cl.company_id) FROM company_locations)
FROM company c
LEFT JOIN company_locations cl
ON c.company_id = cl.company_id
WHERE c.country_code = 'USA'
GROUP BY company_name