当前位置:首页 > 家乡菜系 > 东北菜 > 正文内容

45道计算题怎么写?

2024-09-09 02:34:21东北菜1

oracle数据库网上经典45道练习题及答案写法(有删减)

/*CREATE TABLE STUDENT1

(SNO VARCHAR(3) NOT NULL,

SNAME VARCHAR(4) NOT NULL,

SSEX VARCHAR(2) NOT NULL,

SBIRTHDAY DATE,

CLASS NUMBER NOT NULL);

CREATE TABLE COURSE1

(CNO VARCHAR(5) NOT NULL,

CNAME VARCHAR(10) NOT NULL,

TNO VARCHAR(10) NOT NULL);

CREATE TABLE SCORE1

(SNO VARCHAR(3) NOT NULL,

CNO VARCHAR(5) NOT NULL,

DEGREE NUMBER NOT NULL);

CREATE TABLE TEACHER1

(TNO VARCHAR(3) NOT NULL,

TNAME VARCHAR(4) NOT NULL,

TSEX VARCHAR(2) NOT NULL,

TBIRTHDAY DATE NOT NULL,

PROF VARCHAR(6),

DEPART VARCHAR(10) NOT NULL);*/

/*INSERT INTO STUDENT (SNO,SNAME,SSEX,SBIRTHDAY,CLASS) VALUES (108 ,‘曾华’ ,‘男’ ,to_date(‘1977-09-01’,‘yyyy-mm-dd’),95033);

INSERT INTO STUDENT (SNO,SNAME,SSEX,SBIRTHDAY,CLASS) VALUES (105 ,‘匡明’ ,‘男’ ,to_date(‘1975-10-02’,‘yyyy-mm-dd’),95031);

INSERT INTO STUDENT (SNO,SNAME,SSEX,SBIRTHDAY,CLASS) VALUES (107 ,‘王丽’ ,‘女’ ,to_date(‘1976-01-23’,‘yyyy-mm-dd’),95033);

INSERT INTO STUDENT (SNO,SNAME,SSEX,SBIRTHDAY,CLASS) VALUES (101 ,‘李军’ ,‘男’ ,to_date(‘1976-02-20’,‘yyyy-mm-dd’),95033);

INSERT INTO STUDENT (SNO,SNAME,SSEX,SBIRTHDAY,CLASS) VALUES (109 ,‘王芳’ ,‘女’ ,to_date(‘1975-02-10’,‘yyyy-mm-dd’),95031);

INSERT INTO STUDENT (SNO,SNAME,SSEX,SBIRTHDAY,CLASS) VALUES (103 ,‘陆君’ ,‘男’ ,to_date(‘1974-06-03’,‘yyyy-mm-dd’),95031);

commit;*/

/*INSERT INTO COURSE(CNO,CNAME,TNO)VALUES (‘3-105’ ,‘计算机导论’,825);

INSERT INTO COURSE(CNO,CNAME,TNO)VALUES (‘3-245’ ,‘操作系统’ ,804);

INSERT INTO COURSE(CNO,CNAME,TNO)VALUES (‘6-166’ ,‘数据电路’ ,856);

INSERT INTO COURSE(CNO,CNAME,TNO)VALUES (‘9-888’ ,‘高等数学’ ,100);

commit;*/

/*INSERT INTO SCORE(SNO,CNO,DEGREE)VALUES (103,‘3-245’,86);

INSERT INTO SCORE(SNO,CNO,DEGREE)VALUES (105,‘3-245’,75);

INSERT INTO SCORE(SNO,CNO,DEGREE)VALUES (109,‘3-245’,68);

INSERT INTO SCORE(SNO,CNO,DEGREE)VALUES (103,‘3-105’,92);

INSERT INTO SCORE(SNO,CNO,DEGREE)VALUES (105,‘3-105’,88);

INSERT INTO SCORE(SNO,CNO,DEGREE)VALUES (109,‘3-105’,76);

INSERT INTO SCORE(SNO,CNO,DEGREE)VALUES (101,‘3-105’,64);

INSERT INTO SCORE(SNO,CNO,DEGREE)VALUES (107,‘3-105’,91);

INSERT INTO SCORE(SNO,CNO,DEGREE)VALUES (108,‘3-105’,78);

INSERT INTO SCORE(SNO,CNO,DEGREE)VALUES (101,‘6-166’,85);

INSERT INTO SCORE(SNO,CNO,DEGREE)VALUES (107,‘6-106’,79);

INSERT INTO SCORE(SNO,CNO,DEGREE)VALUES (108,‘6-166’,81);

commit;*/

/*INSERT INTO TEACHER(TNO,TNAME,TSEX,TBIRTHDAY,PROF,DEPART) VALUES (804,‘李诚’,‘男’,to_date(‘1958-12-02’,‘yyyy-mm-dd’),‘副教授’,‘计算机系’);

INSERT INTO TEACHER(TNO,TNAME,TSEX,TBIRTHDAY,PROF,DEPART) VALUES (856,‘张旭’,‘男’,to_date(‘1969-03-12’,‘yyyy-mm-dd’),‘讲师’,‘电子工程系’);

INSERT INTO TEACHER(TNO,TNAME,TSEX,TBIRTHDAY,PROF,DEPART) VALUES (825,‘王萍’,‘女’,to_date(‘1972-05-05’,‘yyyy-mm-dd’),‘助教’,‘计算机系’);

INSERT INTO TEACHER(TNO,TNAME,TSEX,TBIRTHDAY,PROF,DEPART) VALUES (831,‘刘冰’,‘女’,to_date(‘1977-08-14’,‘yyyy-mm-dd’),‘助教’,‘电子工程系’);

commit;*/

–1、查询Student表中的所有记录的Sname、Ssex和Class列。

select sname,ssex,class

from student1;

–2、查询教师所有的单位即不重复的Depart列。

select distinct depart

from teacher1;

–3、查询Student表的所有记录。

select * from student1;

–4、查询Score表中成绩在60到80之间的所有记录。

select * from score1

where degree60;

–5、查询Score表中成绩为85,86或88的记录。

select * from score1

where degree=85 or degree=86 or degree=88;

–6、查询Student表中“95031”班或性别为“女”的同学记录。

select * from student1

where class=‘95031’ or ssex=‘女’;

–7、以Class降序查询Student表的所有记录。

select * from student1

order by class desc;

–8、以Cno升序、Degree降序查询Score表的所有记录。

select * from score1

order by cno asc,degree desc;

–9、查询“95031”班的学生人数。

select count(1)

from student1

where class=‘95031’;

–10、查询Score表中的最高分的学生学号和课程号。

select *

from (select sno,cno,degree

from score1

group by sno,cno,degree

order by degree desc)

where rownum=5)

group by cno;

–13、查询最低分大于70,最高分小于90的Sno列。

select sno

from score1

group by sno

having min(degree)>70 and max(degree)(select degree

from score1 where sno=‘109’ and cno=‘3-105’);

(有问题)–20、查询score中选学一门以上课程的同学中分数为非最高分成绩的记录。

select * from (select sno,cno,degree from score1

group by sno,cno,degree

having count(cno)>1

order by sno asc,degree asc)

where degree != (select max(degree) from(select sno,cno,degree from score1

group by sno,cno,degree

having count(cno)>1));

–21、查询成绩高于学号为“109”、课程号为“3-105”的成绩的所有记录。

select distinct * from score1

where degree>(select degree

from score1

where sno=‘109’ and cno=‘3-105’);

–22、查询和学号为108的同学同年出生的所有学生的Sno、Sname和Sbirthday列。

select sno,sname,sbirthday

from student1

where to_char(sbirthday,‘yyyy’)=(select to_char(sbirthday,‘yyyy’) from student1 where sno=‘108’)

and sno‘108’;

–23、查询“张旭“教师任课的学生成绩。

select degree

from teacher1,score1,course1

where teacher1.tno=course1.tno and score1.cno=course1.cno and tname=‘张旭’;

–24、查询选修某课程的同学人数多于5人的教师姓名

select tname

from teacher1

where tno=(select tno from (select tno,course1.cno from score1,course1

where score1.cno=course1.cno group by tno,course1.cno

having count(1)>5));

–25、查询95033班和95031班全体学生的记录。

select * from student1

where class in (‘95033’,‘95031’)

order by class asc;

–26、查询存在有85分以上成绩的课程Cno.

select distinct cno

from score1

where degree>85;

–27、查询出“计算机系“教师所教课程的成绩表。

select course1.tno,degree

from score1,course1,teacher1

where score1.cno=course1.cno and teacher1.tno=course1.tno

and depart=‘计算机系’

group by course1.tno,degree;

–32、查询所有“女”教师和“女”同学的name、sex和birthday.

select sname,ssex,sbirthday,tname,tsex,tbirthday

from student1,course1,score1,teacher1

where student1.sno=score1.sno and

score1.cno=course1.cno and

teacher1.tno=course1.tno and

ssex=‘女’ and tsex=‘女’

group by sname,ssex,sbirthday,tname,tsex,tbirthday;—不全

分步查询

女学生:

select sname,ssex,sbirthday

from student1

where ssex=‘女’

group by sname,ssex,sbirthday;

女教师:

select tname,tsex,tbirthday

from teacher1

where tsex=‘女’

group by tname,tsex,tbirthday;

–33、查询成绩比该课程平均成绩低的同学的成绩表。

select sno,cno,degree

from score1 b

where degree=2;

–37、查询Student表中不姓“王”的同学记录。

select * from student1

where sname not like ‘王%’;

–38、查询Student表中每个学生的姓名和年龄。

select sname,floor(months_between(sysdate,sbirthday)/12) “年龄”

from student1;

–39、查询Student表中最大和最小的Sbirthday日期值。

select max(sbirthday),min(sbirthday)

from student1;

–40、以班号和年龄从大到小的顺序查询Student表中的全部记录。

select sno,sname,ssex,sbirthday,class,floor(months_between(sysdate,sbirthday)/12) “年龄”

from student1

group by sno,sname,ssex,sbirthday,class

order by class desc,“年龄” desc;

–41、查询“男”教师及其所上的课程。

select course1.cno,tname,tsex,cname

from course1,teacher1,score1

where score1.cno=course1.cno and teacher1.tno=course1.tno and tsex=‘男’

group by course1.cno,tname,tsex,cname;

–42、查询最高分同学的Sno、Cno和Degree列。

select *

from (select sno,cno,degree from score1 group by sno,cno,degree

order by degree desc)

where rownum

本网站文章仅供交流学习 ,不作为商用, 版权归属原作者,部分文章推送时未能及时与原作者取得联系,若来源标注错误或侵犯到您的权益烦请告知,我们将立即删除.

本文链接:http://www.jrjxc.com/jxcx/dbc/860502.html

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。