码迷,mamicode.com
首页 > 数据库 > 详细

SQL面试题1

时间:2019-12-29 12:39:29      阅读:62      评论:0      收藏:0      [点我收藏+]

标签:试题   shu   语句   style   student   HERE   div   span   sql   

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.

SQL面试题1

标签:试题   shu   语句   style   student   HERE   div   span   sql   

原文地址:https://www.cnblogs.com/wuxiping2019/p/12114542.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!