help to creating a formula on mysql to create another column on another table
just starting with mysql... had this table rating with this placement...
http://i.stack.imgur.开发者_JAVA技巧com/kExbh.jpg
i want to get the average value of rating on a specific question_id(example: question_id=1, therefore: (5+4+3)/3=average and question_id=2, therefore:(3+4)/2=average) and transfer the value of average to another table which is result...that would look like below...
http://i.stack.imgur.com/j1erd.jpg
any help will be greatly appreciated...^^
You can use this query:
INSERT INTO results (subject_id, question_id, average)
SELECT subject_id, question_id, AVG(rating)
FROM rating
GROUP BY subject_id, question_id
精彩评论