您好,登錄后才能下訂單哦!
一、
1.新建表 test
id varchar2(20)
name varchar2(20)
addr varchar2(50)
score number
create table test
(id varchar2(20),
name varchar2(20),
addr varchar2(50),
score number
)
2.給id增加主鍵約束
alter table test add constraint pk_id primary key(id)
3.查詢出分數大于60分的人員,并按分數降序進行排列
select * from test where score>60 order by score desc
4.新增數據 001 zhangsan shenzhen 80
insert into test(id,name,addr,score) values ('001','zhansgan','shenzhen','80')
7.刪除zhangsan的信息
delete from test where name='zhangsan'
二、
Student(S#,Sname,Sage,Ssex) 學生表
Course(C#,Cname,T#) 課程表
SC(S#,C#,score) 成績表
Teacher(T#,Tname) 教師表
問題:
1、查詢平均成績大于60分的同學的學號和平均成績; avg
select s#,avg(score) from sc where (select avg(score) from sc)>60 group by s# ;
select s#,avg(score) from sc where group by s# having avg(score)>60;
2、查詢所有同學的學號、姓名、選課數、總成績;
select Student.s#,sname,count(C#),sum(score) from Student inner join sc on Student.s#=sc.s# group by Student.s#,sname
3、查詢姓“李”的老師的個數;
select count(*) from teacher where tname like'李%'
4、查詢沒學過“葉平”老師課的同學的學號、姓名;
select S#,Sname from Student where s# in (select S# from sc where c# not in (select c# from Course where T#=(select T# from teacher where Tname='葉平' ))
5、查詢所有課程成績小于60分的同學的學號、姓名;
select S#,Sname from Student where s# not in (select S# from sc where score>60)
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。