zoukankan      html  css  js  c++  java
  • 数据库建标练习完结篇(32~45)

    --32、查询所有“女”教师和“女”同学的name、sex和birthday.
    
    select sname, ssex, sbirthday from student where ssex = '' 
    union select tname, tsex,tbirthday from teacher where tsex = '';
    
    --33、查询成绩比该课程平均成绩低的同学的成绩表。
    
    select c.cno,c.degree from score c 
    
    where c.degree  < (select avg(s.degree) from score s  where s.cno = c.cno  group by s.cno);
    
    
    --34、 查询所有任课教师的Tname和Depart.
    
    select  t.tname, t.depart from teacher t, course c where t.tno = c.tno;
    
    --35,查询所有未讲课的教师的Tname和Depart.
    
    select distinct t.tname, t.depart from teacher t, course c where t.tno not in (select tno from course);
    
    
    --36、查询至少有2名男生的班号。
    
    select * from (select s.sclass, count(s.sclass) c from student s where s.ssex = '' group by s.sclass) where  c>=2 ;
      
    --37、查询Student表中不姓“王”的同学记录。
    
    select * from student s where s.sname not like '王%'; 
    
    
    --38、查询Student表中每个学生的姓名和年龄。
    
    select s.sname,to_char(sysdate,'yyyy')-to_char(s.sbirthday,'yyyy') from student s;
    
    --39、查询Student表中最大和最小的Sbirthday日期值。
    
    select min(s.sbirthday) 最大生日,max(s.sbirthday) 最小生日 from student s;
    
    --40、以班号和年龄从大到小的顺序查询Student表中的全部记录。
    
    select * from student s order by s.sclass desc ,s.sbirthday;
    
    --41、查询“男”教师及其所上的课程。
    
    select t.tname,c.cname from teacher t,course c where t.tno = c.tno and t.tsex = '';
    
    --42、查询最高分同学的Sno、Cno和Degree列。
    
    select s.sname,c.cname,r.degree from student s ,course c,score r where r.degree = (select max(degree) from score)
    and s.sno = r.sno and c.cno = r.cno;
    
    --43、查询和“李军”同性别的所有同学的Sname.
    select t.sname from student t where t.ssex = (select s.ssex from student s where s.sname = '李军');
    
    
    --44、查询和“李军”同性别并同班的同学Sname.
    
    select t.sname from student t where t.ssex = (select s.ssex from student s where s.sname = '李军') and 
    t.sclass = (select s.sclass from student s where s.sname = '李军');
    
    --45、查询所有选修“计算机导论”课程的“男”同学的成绩表。
    
    
    select t.sname,t.ssex,s.degree from score s,course c,student t where s.cno = c.cno 
    and s.sno = t.sno and t.ssex = '' and c.cname = '计算机导论';
  • 相关阅读:
    骨骼动画的原理及在Unity中的使用
    GUI之ScrollView的使用
    Java编程技术之浅析Java容器技术
    Linux系统 Centos7 环境基于Docker部署Rocketmq服务
    Linux系统环境基于Docker搭建Mysql数据库服务实战
    Java编程技术之浅析JVM内存
    Java编程技术之浅析SPI服务发现机制
    Linux系统环境基于Docker搭建系统基础镜像
    Linux Centos7 环境搭建Docker部署Zookeeper分布式集群服务实战
    Linux Centos7 环境基于Docker部署Zookeeper服务搭建实战
  • 原文地址:https://www.cnblogs.com/HRZJ/p/5972022.html
Copyright © 2011-2022 走看看