SQL经典练习题48道之六(36-40)

接上篇 SQL经典练习题48道之五(31-35)
36、查询所有任课教师的Tname和Depart.
答:
select tname,depart from teacher where tno in (select distinct tno from course where cno in (select cno from score group by cno) );
37、查询所有未讲课的教师的Tname和Depart.
答:
select tname,depart from teacher where tno not in (select distinct tno from course where cno in (select cno from score group by cno) );
38、查询至少有2名男生的班号。
答:
select classnum from student where ssex=’男’ group by classnum having count(*)>1;
39、查询Student表中不姓“王”的同学记录。
答:
select * from student where sname not like ‘王%’;
40、查询Student表中每个学生的姓名和年龄。
答:
select sname,(year(now())-year(sbirthday))age from student;

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值