SqlServer数据查询 |
您所在的位置:网站首页 › ff14数据查询 › SqlServer数据查询 |
以下内容仅供参考 用代码创建四张表(学生表、课程表、成绩表、教师表)
带限制条件的查询和表达式查询 1查询Student表中的所有记录的Sname、Ssex和Class列。 2查询教师所有的单位即不重复的Depart列 3查询Student表的所有记录 4查询Score表中成绩在60到80之间的所有记录 5查询Score表中成绩为85,86或88的记录 6查询Student表中“95031”班或性别为“女”的同学记录 7以Class降序查询Student表的所有记录 8以Cno升序、Degree降序查询Score表的所有记录 9查询“95031”班的学生人数 10查询Score表中的最高分的学生学号和课程号(子查询或者排序) 11查询每门课的平均成绩 12查询Score表中至少有5名学生选修的并以3开头的课程的平均分数 实验方法和步骤 1查询Student表中的所有记录的Sname、Ssex和Class列。select Sname,Ssex,Class from Student;
2查询教师所有的单位即不重复的Depart列 select distinct TDepart from Teacher; 3查询Student表的所有记录 select * from Student;
4查询Score表中成绩在60到80之间的所有记录 select * from Scorewhere Degree between 60 and 80; 5查询Score表中成绩为85,86或88的记录 Select * from Score where Degree in(85,86,88); 6查询Student表中“95031”班或性别为“女”的同学记录 Select * from Student where Class=95031 or Ssex='女'; 7以Class降序查询Student表的所有记录 Select * from Student order by class desc; 8以Cno升序、Degree降序查询Score表的所有记录 select * from score order by Cno,degree desc; 9查询“95031”班的学生人数 select count(class) from student; 10查询Score表中的最高分的学生学号和课程号(子查询或者排序) select sno,cno from score where degree=(select max(degree)from score); 11查询每门课的平均成绩 select cno,avg(degree) from score group by cno; 12查询Score表中至少有5名学生选修的并以3开头的课程的平均分数 select avg(degree) from score where cno = (select cno from score group by cno having count(cno)>=5)And cno like '3%';
|
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |