SQl--学习资料

来源:互联网 发布:世界人工智能大会2018 编辑:程序博客网 时间:2024/06/11 02:50

1、用一条SQL 语句 查询出每门课都大于80 分的学生姓名。(表结构如下图)

这里写图片描述

答案可以有如下两种:

select distinct student_name from table_test_one where student_name not in (select distinct student_name from table_test_one where score<=80);
或者

select student_name from table_test_one group by student_name having min(score)>80;

第二种方法是group by 、min函数 结合 having的使用,w3school教程里面也提到过(在 SQL 中增加 HAVING 子句原因是,WHERE 关键字无法与合计函数一起使用)




0 0
原创粉丝点击