完成以下SQL语句的编写:
student表:
score 表:
查询student表的所有记录
Select * from student;
查询student表的第2条到4条记录
select * from student LIMIT 1,3;
从student表查询所有学生的学号(id)、姓名(name)和院系(department)的信息
Select id,name,departmen from student;
从student表中查询计算机系和英语系的学生的信息
mysql> Select * from student where departmen = "计算机系" or departmen ="英语系";
从student表中查询年龄1985~1990年份的学生信息
Select * from student between 1985 and 1990 ;
从student表中查询每个院系有多少人
Select department,count(*) from student group by department
从score表中查询每个科目的最高分
Select c_name,max(grade) from score group by c_name ;
查询李四的考试科目(c_name)和考试成绩(grade)
Select c_name,grade from score where stu_id in ( select id from student where name="李四");
用连接的方式查询所有学生的信息和考试信息
Select * from score,student;
计算每个学生的总成绩
Select st.name,sum(sc.grade) from score as sc,student as st where st.id=sc.stu_id
group by sc.stu_id;
计算每个考试科目的平均成绩
Select c_name,avg(grade) from score group by c_name ;
查询计算机成绩低于95的学生信息
Select * from student where id in (select stu_id from score where grade < 95);
将计算机考试成绩按从高到低进行排序
Select * from score where c_name = "计算机" order by grade desc;
查询姓张或者姓王的同学的姓名、院系和考试科目及成绩
select st.name,st.department,sc.c_name,sc.grade from student as st, score as sc where st.id = sc.stu_id and name regexp "^[王|张]";
查询都是北京的学生的姓名、年龄、院系和考试科目及成绩
select st.name,st.department,sc.c_name,sc.grade from student as st, score as sc where st.id = sc.stu_id and st.address regexp "^北京";