问题描述
- 求助!!:SQL Server语句查询!!
- 我有一个SQL Server表,表明为:EvaluateTeacherGrade
运行效果如下图:
问题:
用SQL语句我如何得到如下表图示:
即:courseID相同的行其Grade字段各行分别进行累加合并。例如:courseID ShowID Grade teacherID studentID100000 0 10 20070101 0711001 100000 0 10 20070101 0853203 合并后为:courseID ShowID Grade teacherID 100000 0 20 20070101
恳请各位行家高手不吝惜指教!万分感谢!!
解决方案
select courseIDShowIDsum(Grade) GradeteacherID from EvaluateTeacherGrade group by courseID;
解决方案二:
SELECT courseID ShowID SUM(Grade) AS Grade TeacherID FROM EvaluateTeacherGrade
GROUP BY courseID ShowID TeacherID
聚合一下不就行了?
解决方案三:
select ** from ** where **基本上就是这个语法,可以镶嵌使用哦
解决方案四:
首先,谢谢大家的慷慨帮助!再者,我还有一点需要完善!:在如上原问题所示效果图中,我如何得到所有courseID=200002 和teacherID=22222001 的相关信息表,如下表所示:
courseID courseName teacherID teacherName count 200002 德育2 22222001 德育教师1 108
问题:我用如下SQL语句得到的count=90,这是什么原因啊??我该如何改正呢??
SQL语句如下所示:
select C.courseIDC.courseNameC.teacherIDC.teacherNameCount(e.Grade) As count from EvaluateTeacherGrade eCourse CGrade G where e.courseID=G.courseID and e.courseID=C.courseID and e.courseID='200002'and e.teacherID='22222001' GROUP BY C.COURSEIDC.COURSENAMEC.TEACHERIDC.TEACHERNAME
时间: 2024-11-02 03:44:56