Oracle数据库查询语句

来源:百度知道 编辑:UC知道 时间:2024/06/15 22:38:39
问题如下:
表cjd(成绩单)有字段xh(学号),cj(成绩)
表xsmd(学生名单)中有字段,xh(学号),xm(姓名)dh(电话)
1.问题一请用一句sql语句查询出每个人的成绩,显示姓名,成绩,并按照成绩进行排列,分手高的在前。?
2.请用一句查询语句查询出没有成绩的学生名单。?

3 表cjd(成绩单)有字段xh(学号),cj(成绩)
表xsmd(学生名单)中有字段,xh(学号),xm(姓名)dh(电话)
表ljmd(留级名单)中有字段,xh(学号),xm(姓名)dh(电话)
请把以下过程补全,整理出不及格的学生的名单。

declare
i number;
v_temp1 varchar2(100);
v_temp2 varchar2(100);
cursor c1 is
select xh from cjd where cj <60;
rt1 c1%rowtype;
begin
delete from ljmd;
open c1;
fetch c1 into rt1;
while c1%found loop
____________1___________
_____________2__________
end loop;
____3____
close c1;
end;
/
1楼回答的 第二个小问 那个where 条件是 学号<>学号,??
我想要的是没有成绩的学生姓名的名单哦!

1。select a.xm,b.cj from xsmd a,cjd b where a.xh=b.xh order by b.cj desc

2。select a.xm from xsmd a,cjd b where a.xh<>b.xh

3。 declare
i number;
v_temp1 varchar2(100);
v_temp2 varchar2(100);
cursor c1 is
select xh from cjd where cj <60;
rt1 c1%rowtype;
begin
delete from ljmd;
open c1;
fetch c1 into rt1;
while c1%found loop
insert into ljmd select xh,xm,dh from xsmd where xh=rt1;
commit;
end loop;

close c1;
end;

最后一题的第三个空格处我觉得不用写东西了啊

哦,改一下
select xm from xsmd where xh not in (select xh from cjd)

select a.xm,b.cj from xsmd a,cjd b where a.xh=b.xh order by b.cj desc