Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
知道有时一个问题最多可以有 4 个选项,我如何创建脚本来计算每个选项的投票结果?
假设您的表分别命名为table1,table2和table3,可以这样做:
table1
table2
table3
SELECT Question_ID, Option_ID, SUM(Vote) FROM table1 LEFT JOIN table2 USING (Option_ID) GROUP BY Question_ID, Option_ID