0

源数据

从图像中,我有相同的课程 ID 和多个视频,因为我想将整体观看百分比显示为它们的平均值,我该怎么做,我想要这样的东西:

(SELECT SUM(watched_percentage) FROM tbl_student_learning_path where course_id = 298 
AND SELECT COUNT(watched_percentage) FROM tbl_student_learning_path where course_id = 298)
as overallScore 
4

2 回答 2

2

根据评论,您将通过这种方式获得加权平均值

SELECT
    course_id,
    (100 * SUM(watched_total_time) / SUM(video_total_time)) AS WeightedAvg
FROM
    tbl_student_learning_path 
WHERE
    course_id=298
GROUP BY
    course_id
于 2017-05-09T07:33:26.173 回答
1
SELECT course_id,AVG(watched_percentage) AS Avg
FROM tbl_student_learning_path 
WHERE course_id=298
GROUP BY course_id
于 2017-05-09T05:09:16.083 回答