答案 0 :(得分:0)
如果我理解你的问题,就应该这样做。
SELECT tutorid,
CAST((SUM(CASE WHEN rated1 = 1 THEN 1.00 ELSE 0.00 END)+
SUM(CASE WHEN rated2 = 1 THEN 2.00 ELSE 0.00 END)+
SUM(CASE WHEN rated3 = 1 THEN 3.00 ELSE 0.00 END)+
SUM(CASE WHEN rated4 = 1 THEN 4.00 ELSE 0.00 END)+
SUM(CASE WHEN rated5 = 1 THEN 5.00 ELSE 0.00 END))/(COUNT (*))AS DECIMAL(3,2)) 'Average'
FROM YourTable
GROUP BY tutorid
答案 1 :(得分:0)