SQL SUM值来自列并除以行数

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

JW's answer is correct if you're looking specifically to do it by Summing/Dividing, but SQL has a function for that.

SELECT AVG(voto) FROM tablename WHERE id = numberHere

AFAIK, it automatically returns the same type as you input (except date columns, which should be parsed to seconds then re-encoded to date).

AVG should work, count(*) should work, you can also use @@rownum to get the number of rows returned by the statement if you need to do more with that number.