第一题:分建立表,插入数据
---建表语句school_student
CREATE TABLE [dbo].[school_student](
[系名] varchar(20) NULL,
[班级] varchar(20) NULL,
[学号] varchar(9) NULL,
[姓名] varchar(20) NULL,
[年龄] numeric(3,0) NULL,
) ON [PRIMARY]
---建表语句school_class
CREATE TABLE [dbo].[school_class](
[dpt_name] varchar(20) NULL,
[class_name] varchar(20) NULL,
[course_name] varchar(80) NULL,
[mean] numeric(8,6) NULL,
[max] numeric(2,0) NULL,
[min] numeric(2,0) NULL,
) ON [PRIMARY]
---建表数据语句school_student
INSERT INTO school_student(系名,班级,学号,姓名,年龄)
VALUES('计算机系','计算机3001','303100104','王涛',28);
INSERT INTO school_student(系名,班级,学号,姓名,年龄)
VALUES('计算机系','计算机3011','303101101','王悦',27);
INSERT INTO school_student(系名,班级,学号,姓名,年龄)
VALUES('计算机系','信息3032','303303203','王勇',26);
INSERT INTO school_student(系名,班级,学号,姓名,年龄)
VALUES('计算机系','信息3032','303303204','王荣华',26);
INSERT INTO school_student(系名,班级,学号,姓名,年龄)
VALUES('计算机系','信息3032','303303205','王曙',26);
---建表数据语句school_class
INSERT INTO school_class(dpt_name,class_name,course_name,mean,max,min)
VALUES('计算机系','计算机3001','c语言',73.555555,93,45);
INSERT INTO school_class(dpt_name,class_name,course_name,mean,max,min)
VALUES('计算机系','计算机3001','Java程序设计',75.818181,90,64);
INSERT INTO school_class(dpt_name,class_name,course_name,mean,max,min)
VALUES('计算机系','计算机3001','SQL Server2000',72.833333,88,54);
INSERT INTO school_class(dpt_name,class_name,course_name,mean,max,min)
VALUES('计算机系','计算机3001','Visual Basic程序设计',72.444444,90,56);
第二题:
a:语句
SELECT *FROM school_class A LEFT join school_student B ON B.系名=A.dpt_name WHERE A.class_name=B.班级
b:语句
SELECT *FROM school_student A LEFT join school_class B ON A.系名=B.dpt_name AND B.class_name=A.班级
后面的,由于所给素材不够;不方便写。
楼主 晚上帮你写 现在没空