解法一: select courseno,stuno,avg(score) '平均分最高值'--这里是求平均,后面的条件是过滤最大值的 from tablename group by courseno,stuno having avg(score) >= all (select avg(score) sco--这里是过滤最大值 from tablename group by courseno) 解法二: select top 1 with ties courseno,avg(score) '平均…
--CREATE DATABASE EXAM_1 --GO USE EXAM_1 --判断并删除表 IF OBJECT_ID('Scores') IS NOT NULL DROP TABLE Scores; GO IF OBJECT_ID('Courses') IS NOT NULL DROP TABLE Courses; GO IF OBJECT_ID('Students') IS NOT NULL DROP TABLE Students; GO IF OBJECT_ID('Teachers'…
MySQL测试题 一.表关系 请创建如下表,并创建相关约束 创建数据库create database school charset utf8; 建表create table class(cid int not null auto_increment,caption char(32) not null,primary key(cid)); create table student( sid int not null auto_increment, sname char(32) not null,…
Student(S#,Sname,Sage,Ssex) 学生表 Course(C#,Cname,T#) 课程表 SC(S#,C#,score) 成绩表 Teacher(T#,Tname) 教师表 问题: 1.查询“001”课程比“002”课程成绩高的所有学生的学号: select a.S# from (select s#,score from SC where C#='001') a,(select s#,score from SC where C#='002') b where a.…