create table class01(
classno number(4),
classname varchar2(8)
);
select * from class01;
insert into class01 values (101,'甲班');
insert into class01 values (102,'乙班');
commit;
create table student01(
sno number(6),
sname varchar2(6),
score number(3),
classno number(4)
);
insert into student01 values (1001,'张三',77,101);
insert into student01 values (1002,'李四',55,102);
insert into student01 values (1003,'王五',99,101);
create table score01(
minscore number(2),
maxscore number(3),
level01 varchar2(3)
);
alter table score01 modify(level01 varchar2(10));
select * from score01;
insert into score01 values(0,60,'不及格');
insert into score01 values(60,70,'及格');
insert into score01 values(70,80,'良');
insert into score01 values(80,100,'优');问题1:E-R关系设计
问题2:查询出张三的score在表level01中的级别
classno number(4),
classname varchar2(8)
);
select * from class01;
insert into class01 values (101,'甲班');
insert into class01 values (102,'乙班');
commit;
create table student01(
sno number(6),
sname varchar2(6),
score number(3),
classno number(4)
);
insert into student01 values (1001,'张三',77,101);
insert into student01 values (1002,'李四',55,102);
insert into student01 values (1003,'王五',99,101);
create table score01(
minscore number(2),
maxscore number(3),
level01 varchar2(3)
);
alter table score01 modify(level01 varchar2(10));
select * from score01;
insert into score01 values(0,60,'不及格');
insert into score01 values(60,70,'及格');
insert into score01 values(70,80,'良');
insert into score01 values(80,100,'优');问题1:E-R关系设计
问题2:查询出张三的score在表level01中的级别
解决方案 »
- oracle 求指教
- 一个简单的视图问题
- 如何定义常量,使其可以在另一个包中调用
- trigger提示无效且未通过重新确认
- 求sql, 不用存储过程可以实现吧
- 大表删除?
- 请教,怎样在oracle 中用什么函数可以把 varchar型的数据为2004/12/02 上午 10:47:08 转成 日期型,以便我做查询比较.谢谢
- 讨论,哪个方法比较好:是用一个自动产生的SEQUENCE ID作为 表的PRIMARY KEY 还是由几个业务字段联合起来做为PRIMARY KEY?
- 同一个应用程序操作两个不同字符集的ORACLE数据库???
- Orscle11 g数据库连接不上了
- Tableau 怎么连接 Cassandra 数据库
- oracle11g无法与客户端oracle sql developer、java程序代码相连,但sqlplus可以正常使用。
2,通过张三选出的分数在分数等级范围内,类似分数>字段 1 and分数<字段2,也可以可以写成一句,建议分开写,先把分数赋值变量,再查分数等级,减少子查询,sql语句写的越简单对性能越好
select level01 from score01
where (select score from student01 where sname='张三')>minscore
and (select score from student01 where sname='张三')<maxscore;大神,sql语句应该怎么写呢?实在不会呢,求大神教我!
from score01
where (select score from student01 where sname = '张三') between minscore and
maxscore
亲,你是在数据库里写的吗?
我试了,不对!
select level01 from score01,student01
where (student01.score>minscore and student01.score<maxscore)
and student01.sname='张三';
这个能查出来,可是结果是两条记录!谁能优化一下!
亲,你是在数据库里写的吗?
我试了,不对!
select level01 from score01,student01
where (student01.score>minscore and student01.score<maxscore)
and student01.sname='张三';
这个能查出来,可是结果是两条记录!谁能优化一下!
我执行了下,查询只有一条数据:良
where student01.score>=minscore and student01.score<maxscore
and student01.sname='张三';
亲,你是在数据库里写的吗?
我试了,不对!
select level01 from score01,student01
where (student01.score>minscore and student01.score<maxscore)
and student01.sname='张三';
这个能查出来,可是结果是两条记录!谁能优化一下!
我执行了下,查询只有一条数据:良如图,我查的是两条
不过,可以在level01前加distinct,返回结果就是一条
(select sc.level01 from score01 sc where sc.minscore <= score and sc.maxscore > score )
from class01 c1,student01 s1 where c1.classno = s1.classno and s1.sname = '张三' ;
(select sc.level01 from score01 sc where sc.minscore <= s1.score and sc.maxscore > s1.score )
from class01 c1,student01 s1 where c1.classno = s1.classno and s1.sname = '张三' ;给点分吧,赚点分部容易!