Good afternoon, there is a problem with sampling data from MYSQL. I am writing a site for ranking companies and came across a similar problem.
About the problem: There are 2 tables. 2 - companys and the second fileds
Table companys - has columns of which we need only id Table fileds - has columns comp_id, rating
Each company has 5 survey fields in fileds and is linked to the companys (Company).
There is a MYSQL query where JOIN is outputting data from 2 tables, you need to get not 5 results from each company, but a total amount of rating 5 fields under one id.
Sample Request without summation:
SELECT client.companys.id, client.fileds.rating FROM client.companys INNER JOIN client.fileds ON client.companys.id = client.fileds.comp_id Order by rating desc 
select comp_id, sum(rating) from fields group by comp_id- Mike