create database school go USE school CREATE TABLE students ( s_no VARCHAR(20) NOT NULL, s_name VARCHAR(20), s_sex CHAR(2), s_birth DATETIME, s_address VARCHAR(30), s_account MONEY, s_password VARCHAR(20) ) CREATE TABLE courses ( c_no CHAR(10), c_name VARCHAR(30), c_date DATETIME, c_credit INT, c_information VARCHAR(50) ) CREATE TABLE enrollment ( s_no VARCHAR(20), c_no CHAR(10), e_score INT, e_date DATETIME, e_register_state CHAR(1), e_check_state CHAR(1), e_test_state CHAR(1) ) INSERT INTO students VALUES('200920001', '张三', '女', '1982-03-24', '北京市', 8200.0, '200920001') INSERT INTO students VALUES('200920006', '吴八', '男', '1972-12-14', '天津市', 5500.0, '200920006') INSERT INTO courses VALUES('22010401', '高等数学', '2009-03-01', 4, '基础课') INSERT INTO courses VALUES('22010410', '人工智能', '2009-03-01', 2, '专业课') INSERT INTO enrollment VALUES('200920001', '22010409', 88, '2009-3-12', '1', '1', '1') INSERT INTO enrollment VALUES('200920001', '22010410', 93, '2009-3-10', '1', '1', '1') 在此数据库下回答下列10个问题: 1删除修课成绩小于50分和成绩为空的学生的修课记录 2 查询选修了“操作系统”这门课的同学的姓名。 3 将所有选修了"22010410"课程的学生的成绩加10分。 4查询平均成绩高于80分的学生的姓名和他们的平均成绩。 5 查询哪些课程没有人选,要求列出课程号和课程名。 6 使用in查询与“王五”选修至少同一种课程的学生号和课程号。 7 查询没有选修“人工智能”这门课程的同学的姓名。 8 查询选修了课程名称为“数据库应用”的学生号、姓名。 9 查询选修了课程号为“22010410”的学生号和姓名,并以汉字标题显示。 10 查询来自“天津市”的同学所选的课程名。
时间: 2024-01-13 16:03:27 浏览: 267
CreateTable.rar_create table ja_createTab_createTable
好的,我来回答你的问题:
1. DELETE FROM enrollment WHERE (e_score < 50 OR e_score IS NULL);
2. SELECT s_name FROM students WHERE s_no IN (SELECT s_no FROM enrollment WHERE c_no = '22010410');
3. UPDATE enrollment SET e_score = e_score + 10 WHERE c_no = '22010410';
4. SELECT s_name, AVG(e_score) as avg_score FROM students JOIN enrollment ON students.s_no = enrollment.s_no GROUP BY students.s_no HAVING AVG(e_score) > 80;
5. SELECT c_no, c_name FROM courses WHERE c_no NOT IN (SELECT c_no FROM enrollment);
6. SELECT DISTINCT enrollment.s_no, enrollment.c_no FROM enrollment JOIN enrollment AS e ON enrollment.c_no = e.c_no AND e.s_no = '200920006' WHERE enrollment.s_no <> '200920006';
7. SELECT s_name FROM students WHERE s_no NOT IN (SELECT s_no FROM enrollment WHERE c_no = '22010410');
8. SELECT students.s_no, students.s_name FROM students JOIN enrollment ON students.s_no = enrollment.s_no JOIN courses ON courses.c_no = enrollment.c_no WHERE courses.c_name = '数据库应用';
9. SELECT students.s_no AS '学生号', students.s_name AS '姓名' FROM students JOIN enrollment ON students.s_no = enrollment.s_no WHERE enrollment.c_no = '22010410';
10. SELECT courses.c_name FROM courses JOIN enrollment ON courses.c_no = enrollment.c_no JOIN students ON students.s_no = enrollment.s_no WHERE students.s_address = '天津市';
阅读全文