CREATE DATABASE qwe; create table Students ( Sno char(12), Sname VARCHAR(20) not null, Ssex char(2), Syear smallint, Sdept varchar(20) )charset=utf8; CREATE table Courses ( Cno char(8), Cname VARCHAR(20) not null, PreCno VARCHAR(30), Credit char(4) )charset=utf8; create TABLE SC ( Sno char(12), cno char(8), Score char(8) )charset=utf8; INSERT into students VALUES("200201","张三","男",2001,"人工智能学院"); INSERT into students VALUES("200202","李四","男",2002,"人工智能学院"); INSERT into students VALUES("200203","王五","女",2003,"计算机学院"); INSERT into students VALUES("200204","赵六","男",2000,"计算机学院"); INSERT into students VALUES("200205","孙琦","女",2002,"经管学院"); INSERT into students VALUES("200206","刘八","男",2001,"经管学院"); INSERT into students VALUES("200207","曾九","女",2002,"美术学院"); INSERT into students VALUES("200208","陈拾","女",2004,"美术学院"); SELECT * from Students; INSERT into courses VALUES("1001","数据库","程序设计基础","3"); INSERT into courses VALUES("1002","大学语文",null,"2"); INSERT into courses VALUES("1003","高等数学",null,"3"); INSERT into courses VALUES("1004","数据结构",null,"3"); INSERT into courses VALUES("1005","计算机导论",null,"3"); INSERT into courses VALUES("1006","计算机网络",null,"4"); INSERT into courses VALUES("1007","程序设计基础",null,"5"); INSERT into courses VALUES("1008","Java","数据结构","5"); SELECT * from courses; INSERT into SC VALUES("200201","1001","90"); INSERT into SC VALUES("200201","1002","85"); INSERT into SC VALUES("200202","1001","85"); INSERT into SC VALUES("200203","1002","75"); INSERT into SC VALUES("200202","1002","55"); INSERT into SC VALUES("200202","1003","95"); INSERT into SC VALUES("200206","1007","65"); INSERT into SC VALUES("200204","1008","77"); INSERT into SC VALUES("200205","1004","89"); INSERT into SC VALUES("200208","1007","45"); SELECT * from courses; 运行以上SQL代码前提下,查询最高分同学的学号,查询张三同学所有选修课程的总成绩
时间: 2023-06-28 21:11:03 浏览: 83
基于Java语言的qwe设计源码
查询最高分同学的学号:
```
SELECT Sno FROM SC WHERE Score = (SELECT MAX(Score) FROM SC);
```
查询张三同学所有选修课程的总成绩:
```
SELECT SUM(Score) FROM SC WHERE Sno = '200201';
```
阅读全文