SQL单表查询基本操作

  1. 查询计算机系的学生的姓名、年龄。

  2. 查询成绩在70~80分之间的学生的学号、课程号和成绩。

  3. 查询计算机系年龄在18~20之间且性别为“男”的学生的姓名、年龄。

  4. 查找姓王的同学的所有信息。

  5. 查找姓王的两个字的同学的所有信息。

  6. 查询“C001”号课程的最高分。

  7. 查询计算机系学生的最大年龄和最小年龄。

  8. 统计每个系的学生人数。

  9. 统计每门课程的选课人数和考试最高分。

  10. 统计每个学生的选课门数和考试总成绩,并按选课门数升序显示结果。

  11. 查询总成绩超过200分的学生,要求列出学号和总成绩。

  12. 查询选课门数超过2门的学生的学号、平均成绩和选课门数。


1.select Sname,Sage from Student where Sdept='计算机系';
2.select Sno,Cno,Grade from SC where Grade between 70 and 80;
3.select sname,sage from student where (sage between 18 and 20)
and ssex='男' and sdept='计算机系';
4.select *from student where sname like'王%';
5.select * from student where sname like '王%' and len(sname)=2;
6select max(grade)as 最高分 from sc where cno='c001';
7.select max(sage)as 最大年龄 ,min(sage) as 最小年龄 from student
where sdept='计算机系';
8.select count(*)as 学生人数,
sdept from student group by sdept;
9.select count(*)as 选课人数,max(grade)as 最高分,
cno from sc group by cno;
10.select count(*)as 选课门数,sum(grade) as 总分,sno
from sc group by sno order by count(*) asc;
11.select sum(grade)as 总分,sno from sc 
group by sno having sum(grade)>200;
12.select sno,avg(grade)as 平均成绩,count(cno)as 选课门数
from sc group by sno having count(cno)>2;


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值