sql - MYSQL get AVG for each row -
i need avg each row of table. lets have
id val 1 5 2 6 3 7
i need
id val 1 0.277 (5/18) 2 0.333 (6/18) 3 0.388 (7/18)
can easy in mysql without joining same table?
you can sum val column , divide val column sum.
select id, 1.0*val/(select sum(val) tablename) val tablename
Comments
Post a Comment