select course_number ,count(*) as cnt,sum(online_time) as totaltime from stu_study group by course_number where stu_number='20110012'
我的语句如上。
表中字段:
stu_number(学号)
course_number(课程号)
online_time(int,在线时长)
学生有重复值,课程也有重复值,现在想找某一个学生的不同课程的情况.
sqlserver提示:
消息 156,级别 15,状态 1,第 1 行
关键字 'where' 附近有语法错误。
------解决方案--------------------
- SQL code
select course_number ,count(*) as cnt,sum(online_time) as totaltimefrom stu_study where stu_number='20110012' group by course_number
------解决方案--------------------
把where 写着group by 前面
------解决方案--------------------
select course_number ,count(*) as cnt,sum(online_time) as totaltime from stu_study
where stu_number='20110012'
group by course_number
where必须在group by前面