用mysql语句实现1) 在 college 中插入一条数据,学校为'Carnegie Mellon', 所 在州'PA', 入学人数 11500; 2)在 Apply 表中插入数据:没有申请任何学校的学生将申请 Carnegie Mellon 大学的 CS 专业; 将申请信息插入 apply 表中(decision 设置为空值) 3)在 Apply 表中插入数据:允许所有申请 EE 专业被拒绝的学生 进入卡内基梅隆大学 EE 专业(decision 值为‘Y’); 4)从学生表中删除申请了 2 个以上专业的学生信息; 5)从 college 表中删除没有 CS 专业申请记录的大学; 6)更新 Apply 表:录取申请 Carnegie Mellon 大学、GPA 小于 3.6 的学生,录取专业为 economics; 7)更新 Apply 表:将申请 EE 专业具有最高 GPA 学生的专业更新 为 CSE
时间: 2023-06-11 13:04:45 浏览: 170
Indiana-COVIDcast-Dashboard:使用卡内基·梅隆(Carnegie Mellon)的印第安纳州COVIDcast组合指标的仪表板
1)INSERT INTO college (college_name, state, enrollments) VALUES ('Carnegie Mellon', 'PA', 11500);
2)INSERT INTO apply (student_id, college_name, major, decision) SELECT student_id, 'Carnegie Mellon', 'CS', NULL FROM student WHERE NOT EXISTS (SELECT * FROM apply WHERE student.student_id = apply.student_id);
3)INSERT INTO apply (student_id, college_name, major, decision) SELECT student_id, 'Carnegie Mellon', 'EE', 'Y' FROM student WHERE NOT EXISTS (SELECT * FROM apply WHERE student.student_id = apply.student_id AND apply.major = 'EE' AND apply.decision = 'Y');
4)DELETE FROM student WHERE student_id IN (SELECT student_id FROM apply GROUP BY student_id HAVING COUNT(*) > 2);
5)DELETE FROM college WHERE college_name NOT IN (SELECT college_name FROM apply WHERE major = 'CS');
6)UPDATE apply SET major = 'economics' WHERE college_name = 'Carnegie Mellon' AND major <> 'CS' AND gpa < 3.6;
7)UPDATE apply SET major = 'CSE' WHERE college_name = 'Carnegie Mellon' AND major = 'EE' AND gpa = (SELECT MAX(gpa) FROM apply WHERE college_name = 'Carnegie Mellon' AND major = 'EE');
阅读全文