关系数据库的查询建表

1:create table test2_01 as select sid, name
                        from pub.student
                         where sid not in (select distinct sid
                         from pub.student_course);
2:create table test2_02 as select pub.student.sid ,pub.student.name 
from pub.student,pub.student_course
where pub.student.sid=pub.student_course.sid and pub.student_course.cid in(select cid
    from pub.student_course
     where sid='200900130417');
3:select pub.student.sid,pub.student.name
from pub.student,pub.student_course
where pub.student.sid=pub.student_course.sid and
      pub.student_course.cid in(select cid
                                 from pub.course
                               where fcid='300002');
4:create table test2_04 as select pub.student.sid,pub.student.name
from pub.student,pub.student_course,pub.course
where pub.student.sid=pub.student_course.sid and pub.student_course.cid=pub.course.cid and pub.course.name=('数据结构')intersect(select pub.student.sid,pub.student.name
from pub.student,pub.student_course,pub.course
where pub.student.sid=pub.student_course.sid and pub.student_course.cid=pub.course.cid and pub.course.name=('操作系统'));
5:create table test2_05 as select s.sid,name,avg_score,sum_score from
(select sid,round(avg(score),0) avg_score,sum(score) sum_score from pub.student_course group by sid) sc,(select sid,name from pub.student where age=20) s where sc.sid=s.sid
6:create table test2_06 as select  cid,max(score) as max_score
from pub.student_course
group by cid
7:create table test2_07 as select sid, name
from pub.student
where name not like '王%'and name not like '李%'and name not like '张%';
8:create table test2_08 as select second_name,count(second_name)as p_count from (select substr(name,1,1) as second_name from pub.student) group by second_name
9:create table test2_09 as select pub.student.sid,pub.student.name,pub.student_course.score
from pub.student ,pub.student_course
where pub.student.sid=pub.student_course.sid and pub.student_course.cid=
'300003';
10:create table test2_10 as select sid ,cid
from pub.student_course
where score is not null;

转载于:https://my.oschina.net/yanjianhai/blog/124559

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值