码迷,mamicode.com
首页 > 数据库 > 详细

SQL练习

时间:2015-11-04 17:25:26      阅读:304      评论:0      收藏:0      [点我收藏+]

标签:

--18.
create table grade(low number(3),upp number (3),rank char(1));
insert into gGrade values(90,100,‘A‘);
insert into grade values(80,89,‘B‘);
insert into grade values(70,79,‘C‘);
insert into grade values(60,69,‘D‘);
insert into grade values(0,59,‘E‘);

grade表:

技术分享

select SNO,CNO,rank from t_hq_score,grade where DEGREE between low and upp;

技术分享

--19.
select * from t_hq_score where CNO=‘3-105‘and degree >all(select degree from t_hq_score where SNO=‘109‘);

技术分享

--21.
select * from t_hq_score where DEGREE >(select degree from t_hq_score where cno=‘3-105‘and sno=‘109‘);

技术分享

--22.
--最初
select sno,sname,sbirthday from t_hq_student where sbirthday in (select sbirthday from t_hq_student where sno=‘108‘);
--改过后
select sno,sname,sbirthday from t_hq_student where to_char( sbirthday,‘yyyy‘ ) = to_char( (select sbirthday from t_hq_student where sno=‘108‘),‘yyyy‘);

技术分享

--23.
select * from t_hq_score where cno in(select cno from t_hq_course where tno in(select tno from t_hq_teacher where tname=‘张旭‘));

技术分享

--24.
select tname from t_hq_teacher where tno in(select tno from t_hq_course where cno in (select cno from t_hq_score group by cno having count(*)>5));

技术分享

 

SQL练习

标签:

原文地址:http://www.cnblogs.com/zxw0004/p/4936524.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!