我的这个sq执行将近1分钟,请求优化.....

 SELECT Convert(numeric(10,2),SUM(ER.Score*(SE.Rate/100.00))) AS ExerciseScore,ER.StudentUserID
 FROM [db_owner].CourseStatisticRate CS  --课程权重关联表
 INNER JOIN [db_owner].StatisticRateExercise SE ON CS.StatisticRateID = SE.StatisticRateID --权重作业关联表
 INNER JOIN [db_owner].ExerciseResult ER ON  SE.ExerciseSubjectID = ER.ExerciseContentID  --作业结果
 inner join
       (
---这个sql执行将近2万条数据
        select ExerciseResult.ExerciseContentID,ExerciseResult.StudentUserID
        ,MAX(ExerciseResult.ExerciseUploadID) as ExerciseUploadID
        from db_owner.ExerciseResult
        --add by liuzhh 2010.4.30 start
        where Teacher != ''
        --add end
        group by ExerciseResult.ExerciseContentID,ExerciseResult.StudentUserID
       ) as ERM
       on ER.ExerciseContentID = ERM.ExerciseContentID
        and ER.StudentUserID = ERM.StudentUserID
        and ER.ExerciseUploadID = ERM.ExerciseUploadID
     WHERE CS.CourseID = 517 AND CS.ClassID = 26 AND State = 1 AND Score > 0
     GROUP BY ER.StudentUserID

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值