SQ查询联系(一)

1001.查询管理系1990年以前出生的女生姓名、系和出生日期
select sname,sdept,csrq from student
where sdept=‘管理系’ and sex=‘女’ and year(csrq)<‘1990’

1002.查询选修了1号课或3号课成绩都大于80分的的学生的学号和成绩
select sno,grade from sc
where cno in(‘1’,‘3’) and grade>80

1003.查询信息系所有女生年龄大于21的姓名,及所在系及年龄(当前年2010,年龄用age表示)
select sname,sdept,year(date())-year(csrq) as age from student
where sex=‘女’ and sdept=‘信息系’ and (2010-year(csrq))>21

1004.查询课程名含有数据两个字的,先行课程号不为0,学分大于2的的课程的课程号、课程名和学分
select cno,cname,ccredit from course
where cname like ‘%数据%’ and cpno <>‘0’ and ccredit >2

1005.查询计算机系或信息系中年龄介于20与23之间的同学情况,不含20与23.(设当前年为2010年,提示用当前年减去出生年再与20岁,23岁比较)
select * from student
where (sdept=‘计算机系’ or sdept=‘信息系’) and (2010-year(csrq))>20 and (2010-year(csrq))<23

1006.查询名字中第3个字为玲4月4号出生的学生的姓名和学号
select sname,sno from student
where sname like ‘__玲%’ and month(csrq)=4 and day(csrq)=4

1007.查询所有名字中含有“小”的非信息系同学的的姓名和系
select sname,sdept from student
where sname like ‘%小%’ and sdept not in (‘信息系’)

1008.查询管理系所有非李姓的2009及2010级同学情况
select * from student
where sdept=‘管理系’ and sname not like ‘李%’ and (sno like ‘2009%’ or sno like ‘2010%’)

1009.查询所有出生为90后的计算机系的两字李姓同学及管理系的两字王姓同学的情况
select * from student
where year(csrq)>=1990 and((sname like ‘李_’ and sdept=‘计算机系’ ) or (sname like’王_’ and sdept=‘管理系’))

1010.请查询计算机系或文传系2011级90后4月出生的女生情况。
select * from student
where sno like ‘2011%’ and year(csrq)>=1990 and month(csrq)=4 and sex=‘女’ and (sdept =‘计算机系’ or sdept=‘文传系’)

  • 1
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值