I'm trying to calculate a percentual...and I need to sum all values from a column (Its already ok) but I need divide the result by number of rows...
select sum(voto) from tablename where id = numberHere
I'm trying to calculate a percentual...and I need to sum all values from a column (Its already ok) but I need divide the result by number of rows...
select sum(voto) from tablename where id = numberHere
use COUNT
to get the totalNumber of rows.
SELECT SUM(voto) / (COUNT(*) * 1.0)
FROM tablename
WHERE id = numberHere
by adding * 1.0
on the query will allow decimal places on the result.
or simply as
SELECT AVG(voto)
FROM tablename
WHERE id = numberHere