Auto commit
This commit is contained in:
parent
783148afe6
commit
29925804ff
@ -305,6 +305,53 @@ DELIMITER ;
|
||||
### 第四套
|
||||
|
||||
```sql
|
||||
#1
|
||||
ALTER TABLE tb_students MODIFY gender ENUM('男', '女', '未知');
|
||||
#2
|
||||
ALTER TABLE tb_scores MODIFY score FLOAT(7, 2);
|
||||
#3
|
||||
CREATE TABLE tb_scores_bak1 AS
|
||||
SELECT *
|
||||
FROM tb_scores;
|
||||
#4
|
||||
UPDATE test1 t1, (
|
||||
SELECT tname, CONCAT(tname,'@',COUNT(*)) str
|
||||
FROM test1
|
||||
GROUP BY tname
|
||||
HAVING COUNT(*) IN (3, 4)
|
||||
)t2
|
||||
SET t1.tname = t2.str
|
||||
WHERE t1.tname = t2.tname;
|
||||
|
||||
#5
|
||||
SELECT *
|
||||
FROM tb_courses c
|
||||
ORDER BY c.cid+0
|
||||
LIMIT 4, 11;
|
||||
|
||||
#6
|
||||
SELECT s.stuname, TIMESTAMPDIFF(YEAR,s.birthday,'2023-12-01')
|
||||
FROM tb_students s
|
||||
WHERE TIMESTAMPDIFF(YEAR,s.birthday,'2023-12-01') BETWEEN 30 AND 40;
|
||||
|
||||
#7
|
||||
SELECT st.stuname, st.gender, st.birthday, c.cname, sc.score,
|
||||
IF(sc.score >= 90, '优秀',
|
||||
IF(sc.score >= 80, '良好',
|
||||
IF(sc.score >= 70, '中等',
|
||||
IF(sc.score >= 60, '及格', '不及格'))))
|
||||
FROM tb_students st, tb_scores sc, tb_courses c
|
||||
WHERE st.stuid = sc.student_id AND sc.course_id = c.cid
|
||||
ORDER BY sc.score DESC;
|
||||
|
||||
#8
|
||||
CREATE VIEW v_scores AS
|
||||
SELECT c.cname, CEIL(AVG(sc.score)), MAX(sc.score), MIN(sc.score)
|
||||
FROM tb_students st, tb_scores sc, tb_courses c
|
||||
WHERE st.stuid = sc.student_id AND sc.course_id = c.cid
|
||||
GROUP BY c.cid;
|
||||
|
||||
#9
|
||||
DELIMITER $$
|
||||
CREATE TRIGGER tri_updateAgeGroup
|
||||
BEFORE UPDATE ON tb_students
|
||||
|
Loading…
x
Reference in New Issue
Block a user