当前位置:   article > 正文

软件工程SQL练习_查询年龄大于等于 20 岁的学生的学号、姓名和年龄

查询年龄大于等于 20 岁的学生的学号、姓名和年龄

1、查询选修了1号课或3号课成绩都大于80分的的学生的学号和成绩

select  sno ,grade 
from sc
where cno in('1' , '3') and grade >80;
  • 1
  • 2
  • 3

2、查询管理系1990年以前出生的女生姓名、系和出生日期

select sname ,sdept ,csrq
from student
where sdept='管理系' and year(csrq)<'1990'  and sex='女';
  • 1
  • 2
  • 3

3、 查询信息系所有女生年龄大于21的姓名,及所在系及年龄(当前年2010,年龄用age表示)

select sname ,sdept , year(date()) -   year(csrq) as age

from student 

where sdept='信息系' and sex='女'

and (2010-year(csrq))>21;

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

4、查询课程名含有数据两个字的,先行课程号不为0,学分大于2的的课程的课程号、课程名和学分

select cno,cname,ccredit
from course
where cname like '%数据%' and cpno <>'0 'and ccredit>2;
  • 1
  • 2
  • 3

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);
  • 1
  • 2
  • 3
  • 4
  • 5

6、查询名字中第3个字为玲4月4号出生的学生的姓名和学号

select sname ,sno
from student
where sname like '__玲%' and  month(csrq)=4 and  day(csrq)=4;
  • 1
  • 2
  • 3

7、 查询所有名字中含有“小”的非信息系同学的的姓名和系

select sname ,sdept
from student
where sname like '%小%'  
and  sdept not like '信息系';

  • 1
  • 2
  • 3
  • 4
  • 5

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='计算机系'));

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15

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='女';
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/article/detail/40071
推荐阅读
相关标签
  

闽ICP备14008679号