首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往
您找到你想要的搜索结果了吗?
是的
没有找到

MySQL窗口函数的妙用

create table grade ( id int(10) primary key auto_increment comment '主键', stu_id int(10) comment '学生id', class_id int(10) comment '班级id', course_id int(3) comment '课程id', score int(3) comment '学生分数', unique key (stu_id, course_id) ) engine = innodb charset = utf8; insert into grade (stu_id, class_id, course_id, score) values ('1', 1, 1, 90), ('4', 1, 1, 90), ('7', 1, 1, 84), ('10', 1, 1, 84), ('13', 1, 1, 88), ('1', 1, 2, 67), ('4', 1, 2, 85), ('7', 1, 2, 90), ('10', 1, 2, 88), ('13', 1, 2, 86); insert into grade (stu_id, class_id, course_id, score) values ('2', 2, 1, 83), ('5', 2, 1, 94), ('8', 2, 1, 81), ('11', 2, 1, 91), ('14', 2, 1, 79), ('2', 2, 2, 99), ('5', 2, 2, 80), ('8', 2, 2, 82), ('11', 2, 2, 76), ('14', 2, 2, 66); insert into grade (stu_id, class_id, course_id, score) values ('3', 3, 1, 98), ('6', 3, 1, 92), ('9', 3, 1, 76), ('12', 3, 1, 73), ('15', 3, 1, 83), ('3', 3, 2, 95), ('6', 3, 2, 91), ('9', 3, 2, 86), ('12', 3, 2, 87), ('15', 3, 2, 68); 这里就是建立了一个成绩表,然后往表中插入了15个学生,他们来自三个班级,每个学生学习了两门课程。

02
领券