I have a generic question that I will try to explain using an example.
Say I have a table with the fields: \"id\", \"name\", \"category\", \"appearances\" and \"rati
This is how it is done in mssql, I think mysql is the same or similar:
create table T (id int, ratio float, appearances int)
insert T values (1, null, 2)
insert T values (1, null, 3)
update T
set ratio = cast(appearances as float)/ agg.appearancesSum
from T join (
select id, sum(appearances) as appearancesSum
from T
group by id
) as agg on t.id = agg.id