Do you not have access to the mysql manual, nor to any sql tutorials? The particular thing you're seeking is <b>sum()</b> as in:
select sum(rating) from table;
However, if this particular sql function is new to you, you're likely to have a lot of other problems, too, so I repeat:
Get a copy of the mysql manual handy (www.mysql.net) and check out one or more of the sql tutorials available here and at other sites such as webmonkey, devshed, and others such as:
www.sqlcourse.com
w3.one.net/~jhoffman/sqltut.htm