根据学生课程数据库中的数据,要求完成下列操作:
1.从student表中查询数据,只显示学生编号、姓名、性别三个字段。
select sno,sname,ssex from student;
2.查找student表中所有男同学的信息。
select * from student where ssex='男';
3.查找“计算机系”学生信息并按学号进行降序排序。
select * from student where sdept='计算机系' order by sno desc;
4.查找年龄为“20”的所有学生信息并按性别进行升序排序,如果性别相同再按学号进降序。
select * from student order by ssex asc,sno desc;
5.从学生选课表(SC)中查询成绩在80至90分之间的所有记录并按分数从高到低排序。 将查询到的成绩乘0.6的系数再显示。
select distinct grade*0.6 from sc where grade between 80 and 90 order by grade desc;
6.查询信息系 并且名字中包含”励”的所有学生信息。
select * from student where sname like "%励";
7.查询学生表姓“刘“ 的所有学生信息。
select * from student where sname like "刘%";
8.查询学生表中 姓名 以”刘“开头,并且姓名是二个字的学生信息。
select * from student where sname like "刘_";
9.查询课程表中有先行课的课程信息
select * from course where cpno is not null;
10.查询学生表中有多少个不重复的姓名
select sname ,count(*)from student group by sname having count(*)=1;