关系数据库的查询建表
生活随笔
收集整理的這篇文章主要介紹了
关系数据库的查询建表
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
2019獨角獸企業重金招聘Python工程師標準>>>
1:create table test2_01 as select sid, namefrom pub.studentwhere sid not in (select distinct sidfrom 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 cidfrom pub.student_coursewhere sid='200900130417'); 3:select pub.student.sid,pub.student.name from pub.student,pub.student_course where pub.student.sid=pub.student_course.sid andpub.student_course.cid in(select cidfrom pub.coursewhere 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
總結
以上是生活随笔為你收集整理的关系数据库的查询建表的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 排序相关算法-1
- 下一篇: WIN7做无线路由供手机上网