SQL面试题1

时间:2022-03-16 04:47:24

1.用一条SQL 语句 查询出每门课都大于80 分的学生姓名

mysql> select * from students;
 ---------- --------- -------- 
| name     | kecheng | fenshu |
 ---------- --------- -------- 
| zhangsan | yuwen   |     81 |
| zhangsan | shuxue  |     75 |
| lisi     | yuwen   |     76 |
| lisi     | shuxue  |     76 |
| wangwu   | yuwen   |     81 |
| wangwu   | shuxue  |    100 |
| wangwu   | yingyu  |     90 |
 ---------- --------- -------- 

mysql> select distinct name from students where name not in (select distinct name from students where fenshu<=80);
--------
| name |
--------
| wangwu |

 

mysql> select name from students group by name having min(fenshu)>80;
--------
| name |
--------
| wangwu |
--------

 

2.