Just got this answer from a previous question and it works a treat!
SELECT username, (SUM(rating)/COUNT(*)) as TheAverage, Count(*) as TheCount FROM ratings
The problem here mainly, just Cast the field like this cast(field as varchar) or cast(fields as date)