赞
踩
1、查询选修了1号课或3号课成绩都大于80分的的学生的学号和成绩
select sno ,grade
from sc
where cno in('1' , '3') and grade >80;
2、查询管理系1990年以前出生的女生姓名、系和出生日期
select sname ,sdept ,csrq
from student
where sdept='管理系' and year(csrq)<'1990' and sex='女';
3、 查询信息系所有女生年龄大于21的姓名,及所在系及年龄(当前年2010,年龄用age表示)
select sname ,sdept , year(date()) - year(csrq) as age
from student
where sdept='信息系' and sex='女'
and (2010-year(csrq))>21;
4、查询课程名含有数据两个字的,先行课程号不为0,学分大于2的的课程的课程号、课程名和学分
select cno,cname,ccredit
from course
where cname like '%数据%' and cpno <>'0 'and ccredit>2;
5、查询计算机系或信息系中年龄介于20与23之间的同学情况,不含20与23.(设当前年为2010年,提示用当前年减去出生年再与20岁,23岁比较)
select *
from student
where ( sdept ='计算机系' or sdept='信息系')
and
(year(csrq)-2010>20 or year(csrq)-2010<23);
6、查询名字中第3个字为玲4月4号出生的学生的姓名和学号
select sname ,sno
from student
where sname like '__玲%' and month(csrq)=4 and day(csrq)=4;
7、 查询所有名字中含有“小”的非信息系同学的的姓名和系
select sname ,sdept
from student
where sname like '%小%'
and sdept not like '信息系';
8、查询管理系所有非李姓的2009及2010级同学情况
select *
from student
where sdept ='管理系' and
sname not like '李%'
and sno like '2009%' or sno like '2010%';```
9、 查询所有出生为90后的计算机系的两字李姓同学及管理系的两字王姓同学的情况
```sql
select *
from student
where year(csrq)>=1990
and (( sdept='计算机系' and sname like '李_') or (sname='王_' and sdept='计算机系'));
10、请查询计算机系或文传系2011级90后4月出生的女生情况。
select *
from student
where (sdept='计算机系' or sdept='文传系')
and sno like '2011%'
and
year(csrq)>=1990
and month(csrq)=4 and sex='女';
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。