数据库练习题
2020-09-08 本文已影响0人
既然何必
答案:
创建表cust与mark。
1.写出计算所有学生的英语平均成绩的sql语句
select avg(english) "英语平均成绩" from mark
2.现在有五个学生,假定其学号分别为11.22.33.44.55,请用一条sql语句实现列出这五个学生的数学成绩,及其姓名,住址,电话
SELECT cust. NAME,cust.address,cust.telno,mark.math FROM cust JOIN mark ON cust.studentno = mark.studentno WHERE cust.studentno in(11,22,33,44,55)
3.查询所有学生的姓名,计算机成绩,按照计算机成绩从高到低排序
select cust.name,mark.computer from cust join mark on cust.studentno = mark.studentno ORDER BY mark.computer DESC
4.查询所有总成绩大于240分的学生的学号,姓名,总成绩,按照总成绩从高到低排序
SELECT cust.studentno,cust.NAME,sum(english+math+computer ) AS total FROM cust JOIN mark ON cust.studentno = mark.studentno GROUP BY cust.studentno HAVING total > 240 ORDER BY total DESC